15768: collection copy dialog mostly works Arvados-DCO-1.1-Signed-off-by: Lisa Knox...
[arvados-workbench2.git] / src / store / auth / auth-action-session.ts
index c871e147d1c249f4f5f699196f90eb33598023ae..7e81f2d952ebed3bf81353a4e6a6e2518a91044d 100644 (file)
@@ -3,22 +3,22 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { Dispatch } from "redux";
-import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
-import { RootState } from "~/store/store";
-import { ServiceRepository, createServices, setAuthorizationHeader } from "~/services/services";
+import { setBreadcrumbs } from "store/breadcrumbs/breadcrumbs-actions";
+import { RootState } from "store/store";
+import { ServiceRepository, createServices, setAuthorizationHeader } from "services/services";
 import Axios, { AxiosInstance } from "axios";
-import { User, getUserDisplayName } from "~/models/user";
-import { authActions } from "~/store/auth/auth-action";
+import { User, getUserDisplayName } from "models/user";
+import { authActions } from "store/auth/auth-action";
 import {
     Config, ClusterConfigJSON, CLUSTER_CONFIG_PATH, DISCOVERY_DOC_PATH,
     buildConfig, mockClusterConfigJSON
-} from "~/common/config";
-import { normalizeURLPath } from "~/common/url";
-import { Session, SessionStatus } from "~/models/session";
-import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
-import { AuthService } from "~/services/auth-service/auth-service";
-import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
-import * as jsSHA from "jssha";
+} from "common/config";
+import { normalizeURLPath } from "common/url";
+import { Session, SessionStatus } from "models/session";
+import { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions";
+import { AuthService } from "services/auth-service/auth-service";
+import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
+import jsSHA from "jssha";
 
 const getClusterConfig = async (origin: string, apiClient: AxiosInstance): Promise<Config | null> => {
     let configFromDD: Config | undefined;
@@ -27,6 +27,7 @@ const getClusterConfig = async (origin: string, apiClient: AxiosInstance): Promi
         configFromDD = {
             baseUrl: normalizeURLPath(dd.baseUrl),
             keepWebServiceUrl: dd.keepWebServiceUrl,
+            keepWebInlineServiceUrl: dd.keepWebInlineServiceUrl,
             remoteHosts: dd.remoteHosts,
             rootUrl: dd.rootUrl,
             uuidPrefix: dd.uuidPrefix,
@@ -55,7 +56,7 @@ const getClusterConfig = async (origin: string, apiClient: AxiosInstance): Promi
     return null;
 };
 
-const getRemoteHostConfig = async (remoteHost: string, useApiClient?: AxiosInstance): Promise<Config | null> => {
+export const getRemoteHostConfig = async (remoteHost: string, useApiClient?: AxiosInstance): Promise<Config | null> => {
     const apiClient = useApiClient || Axios.create({ headers: {} });
 
     let url = remoteHost;
@@ -98,7 +99,7 @@ export const getSaltedToken = (clusterId: string, token: string) => {
         throw new Error(invalidV2Token);
     }
     let salted = secret;
-    if (uuid.substr(0, 5) !== clusterId) {
+    if (uuid.substring(0, 5) !== clusterId) {
         shaObj.setHMACKey(secret, "TEXT");
         shaObj.update(clusterId);
         salted = shaObj.getHMAC("HEX");
@@ -116,7 +117,7 @@ export const validateCluster = async (config: Config, useToken: string):
     const svc = createServices(config, { progressFn: () => { }, errorFn: () => { } });
     setAuthorizationHeader(svc, saltedToken);
 
-    const user = await svc.authService.getUserDetails();
+    const user = await svc.authService.getUserDetails(false);
     return {
         user,
         token: saltedToken,
@@ -191,10 +192,11 @@ export const validateSessions = (useApiClient?: AxiosInstance) =>
                           places in Workbench2. */
                         await dispatch(validateSession(session, activeSession, useApiClient));
                     } catch (e) {
-                        dispatch(snackbarActions.OPEN_SNACKBAR({
-                            message: e.message,
-                            kind: SnackbarKind.ERROR
-                        }));
+                        // Don't do anything here.  User may get
+                        // spammed with multiple messages that are not
+                        // helpful.  They can see the individual
+                        // errors by going to site manager and trying
+                        // to toggle the session.
                     }
                 }
             }