1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { AxiosInstance } from "axios";
6 import { ApiActions } from "~/services/api/api-actions";
7 import { AccountToLink } from "~/models/link-account";
8 import { CommonService } from "~/services/common-service/common-service";
10 export const USER_LINK_ACCOUNT_KEY = 'accountToLink';
12 export class LinkAccountService {
15 protected serverApi: AxiosInstance,
16 protected actions: ApiActions) { }
18 public saveToSession(account: AccountToLink) {
19 sessionStorage.setItem(USER_LINK_ACCOUNT_KEY, JSON.stringify(account));
22 public removeFromSession() {
23 sessionStorage.removeItem(USER_LINK_ACCOUNT_KEY);
26 public getFromSession() {
27 const data = sessionStorage.getItem(USER_LINK_ACCOUNT_KEY);
28 return data ? JSON.parse(data) as AccountToLink : undefined;
31 public linkAccounts(newUserToken: string, newGroupUuid: string) {
33 new_user_token: newUserToken,
34 new_owner_uuid: newGroupUuid,
35 redirect_to_new_user: true
37 return CommonService.defaultResponse(
38 this.serverApi.post('/users/merge/', params),