15088: Saves account link data in session storage and logs out
[arvados-workbench2.git] / src / store / link-account-panel / link-account-panel-actions.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from "redux";
6 import { RootState } from "~/store/store";
7 import { ServiceRepository } from "~/services/services";
8 import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
9 import { LinkAccountType, AccountToLink } from "~/models/link-account";
10 import { logout } from "~/store/auth/auth-action";
11
12 export const loadLinkAccountPanel = () =>
13     (dispatch: Dispatch<any>) => {
14        dispatch(setBreadcrumbs([{ label: 'Link account'}]));
15     };
16
17 export const saveAccountLinkData = (t: LinkAccountType) =>
18     (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
19         const accountToLink = {type: t, userToken: services.authService.getApiToken()} as AccountToLink;
20         sessionStorage.setItem("accountToLink", JSON.stringify(accountToLink));
21         dispatch(logout());
22     };