1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 const API_TOKEN_KEY = 'api_token';
6 const API_HOST = 'https://qr1hi.arvadosapi.com';
8 export default class AuthService {
10 public saveApiToken(token: string) {
11 localStorage.setItem(API_TOKEN_KEY, token);
14 public removeApiToken() {
15 localStorage.removeItem(API_TOKEN_KEY);
18 public getApiToken() {
19 return localStorage.getItem(API_TOKEN_KEY);
22 public isUserLoggedIn() {
23 return this.getApiToken() !== null;
27 const currentUrl = `${window.location.protocol}//${window.location.host}/token`;
28 window.location.href = `${API_HOST}/login?return_to=${currentUrl}`;
32 this.removeApiToken();