1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Redirect, RouteProps } from "react-router";
6 import * as React from "react";
7 import { connect, DispatchProp } from "react-redux";
8 import { getUserDetails, saveApiToken } from "~/store/auth/auth-action";
9 import { getUrlParameter } from "~/common/url";
10 import { AuthService } from "~/services/auth-service/auth-service";
12 interface ApiTokenProps {
13 authService: AuthService;
16 export const ApiToken = connect()(
17 class extends React.Component<ApiTokenProps & RouteProps & DispatchProp<any>, {}> {
19 const search = this.props.location ? this.props.location.search : "";
20 const apiToken = getUrlParameter(search, 'api_token');
21 this.props.dispatch(saveApiToken(apiToken));
22 this.props.dispatch<any>(getUserDetails());
25 return <Redirect to="/"/>;