X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dec81d42222814723ff0386665928045ff41eac8..abe9787195984a919095b4a4c2b82c7a0baf0801:/src/store/auth/auth-action-session.ts diff --git a/src/store/auth/auth-action-session.ts b/src/store/auth/auth-action-session.ts index 5b8acf9aeb..c1b97adc3e 100644 --- a/src/store/auth/auth-action-session.ts +++ b/src/store/auth/auth-action-session.ts @@ -5,7 +5,7 @@ import { Dispatch } from "redux"; import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions"; import { RootState } from "~/store/store"; -import { ServiceRepository } from "~/services/services"; +import { ServiceRepository, createServices, setAuthorizationHeader } from "~/services/services"; import Axios from "axios"; import { getUserFullname, User } from "~/models/user"; import { authActions } from "~/store/auth/auth-action"; @@ -16,7 +16,7 @@ import { import { normalizeURLPath } from "~/common/url"; import { Session, SessionStatus } from "~/models/session"; import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions"; -import { AuthService, UserDetailsResponse } from "~/services/auth-service/auth-service"; +import { AuthService } from "~/services/auth-service/auth-service"; import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions"; import * as jsSHA from "jssha"; @@ -81,15 +81,6 @@ const getRemoteHostConfig = async (remoteHost: string): Promise = return null; }; -const getUserDetails = async (baseUrl: string, token: string): Promise => { - const resp = await Axios.get(`${baseUrl}/users/current`, { - headers: { - Authorization: `OAuth2 ${token}` - } - }); - return resp.data; -}; - const invalidV2Token = "Must be a v2 token"; export const getSaltedToken = (clusterId: string, token: string) => { @@ -113,19 +104,13 @@ export const validateCluster = async (config: Config, useToken: string): Promise<{ user: User; token: string }> => { const saltedToken = getSaltedToken(config.uuidPrefix, useToken); - const user = await getUserDetails(config.baseUrl, saltedToken); + + const svc = createServices(config, { progressFn: () => { }, errorFn: () => { } }); + setAuthorizationHeader(svc, saltedToken); + + const user = await svc.authService.getUserDetails(); return { - user: { - firstName: user.first_name, - lastName: user.last_name, - uuid: user.uuid, - ownerUuid: user.owner_uuid, - email: user.email, - isAdmin: user.is_admin, - isActive: user.is_active, - username: user.username, - prefs: user.prefs - }, + user, token: saltedToken, }; };