X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/84c94f372cead175c61c3dd1c69486ce87d91539..3dad010ab289e3409827221ee2a337b4417ee5df:/src/services/link-account-service/link-account-service.ts diff --git a/src/services/link-account-service/link-account-service.ts b/src/services/link-account-service/link-account-service.ts index fe78d484..6c03eed5 100644 --- a/src/services/link-account-service/link-account-service.ts +++ b/src/services/link-account-service/link-account-service.ts @@ -3,27 +3,55 @@ // SPDX-License-Identifier: AGPL-3.0 import { AxiosInstance } from "axios"; -import { ApiActions } from "~/services/api/api-actions"; -import { AccountToLink } from "~/models/link-account"; +import { ApiActions } from "services/api/api-actions"; +import { AccountToLink, LinkAccountStatus } from "models/link-account"; +import { CommonService } from "services/common-service/common-service"; export const USER_LINK_ACCOUNT_KEY = 'accountToLink'; +export const ACCOUNT_LINK_STATUS_KEY = 'accountLinkStatus'; export class LinkAccountService { constructor( - protected apiClient: AxiosInstance, + protected serverApi: AxiosInstance, protected actions: ApiActions) { } - public saveLinkAccount(account: AccountToLink) { + public saveAccountToLink(account: AccountToLink) { sessionStorage.setItem(USER_LINK_ACCOUNT_KEY, JSON.stringify(account)); } - public removeLinkAccount() { + public removeAccountToLink() { sessionStorage.removeItem(USER_LINK_ACCOUNT_KEY); } - public getLinkAccount() { + public getAccountToLink() { const data = sessionStorage.getItem(USER_LINK_ACCOUNT_KEY); return data ? JSON.parse(data) as AccountToLink : undefined; } -} \ No newline at end of file + + public saveLinkOpStatus(status: LinkAccountStatus) { + sessionStorage.setItem(ACCOUNT_LINK_STATUS_KEY, JSON.stringify(status)); + } + + public removeLinkOpStatus() { + sessionStorage.removeItem(ACCOUNT_LINK_STATUS_KEY); + } + + public getLinkOpStatus() { + const data = sessionStorage.getItem(ACCOUNT_LINK_STATUS_KEY); + return data ? JSON.parse(data) as LinkAccountStatus : undefined; + } + + public linkAccounts(newUserToken: string, newGroupUuid: string) { + const params = { + new_user_token: newUserToken, + new_owner_uuid: newGroupUuid, + redirect_to_new_user: true + }; + return CommonService.defaultResponse( + this.serverApi.post('/users/merge', params), + this.actions, + false + ); + } +}