15803: If user is inactive, attempt to self-activate.
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Thu, 7 Nov 2019 16:33:33 +0000 (11:33 -0500)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Thu, 7 Nov 2019 16:33:33 +0000 (11:33 -0500)
This mimics the behavior of workbench 1, however we don't support
displaying / signing user agreements.

src/services/user-service/user-service.ts
src/store/auth/auth-action.ts

index bcf81d554967a298b3e7f89d2716e15689780a3d..ddb9a3646b33e11717e89b0380e17d37711e9b04 100644 (file)
@@ -12,6 +12,14 @@ export class UserService extends CommonResourceService<UserResource> {
         super(serverApi, "users", actions);
     }
 
+    activate(uuid: string) {
+        return CommonResourceService.defaultResponse(
+            this.serverApi
+                .post(this.resourceType + `${uuid}/activate`),
+            this.actions
+        );
+    }
+
     unsetup(uuid: string) {
         return CommonResourceService.defaultResponse(
             this.serverApi
index 9f18b5b029ea30e153fb9b59ec911630d1f5d722..cadf3c6e5e85593cde1069c1320333b0cf6ced70 100644 (file)
@@ -81,6 +81,11 @@ const init = (config: Config) => (dispatch: Dispatch, getState: () => RootState,
         dispatch<any>(initSessions(services.authService, config, user));
         dispatch<any>(getUserDetails()).then((user: User) => {
             dispatch(authActions.INIT({ user, token }));
+            if (!user.isActive) {
+                services.userService.activate(user.uuid).then((user: User) => {
+                    dispatch(authActions.INIT({ user, token }));
+                });
+            }
         }).catch((err: AxiosError) => {
             if (err.response) {
                 // Bad token