21691: Add type to login method to satisfy result type
authorStephen Smith <stephen@curii.com>
Fri, 12 Apr 2024 00:27:50 +0000 (20:27 -0400)
committerStephen Smith <stephen@curii.com>
Fri, 12 Apr 2024 13:13:37 +0000 (09:13 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

services/workbench2/src/views-components/login-form/login-form.tsx
services/workbench2/src/views/login-panel/login-panel.tsx

index 6c5902653bb3cdf21b1416430dfcdd4af6881ad3..7d71078c31d1b69af4e3e636f52e9193acd5d15e 100644 (file)
@@ -13,6 +13,7 @@ import { DispatchProp } from 'react-redux';
 import { saveApiToken } from 'store/auth/auth-action';
 import { navigateToRootProject } from 'store/navigation/navigation-action';
 import { replace } from 'react-router-redux';
+import { PasswordLoginResponse } from 'views/login-panel/login-panel';
 
 type CssRules = 'root' | 'loginBtn' | 'card' | 'wrapper' | 'progress';
 
@@ -46,7 +47,7 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
 });
 
 type LoginFormProps = DispatchProp<any> & WithStyles<CssRules> & {
-    handleSubmit: (username: string, password: string) => AxiosPromise;
+    handleSubmit: (username: string, password: string) => AxiosPromise<PasswordLoginResponse>;
     loginLabel?: string,
 };
 
index f834b3b6dfcaf2346890fd9d38da848a20f60ad4..452a66672a327bd9fd67db950efb295136d96efe 100644 (file)
@@ -10,7 +10,7 @@ import { login, authActions } from 'store/auth/auth-action';
 import { ArvadosTheme } from 'common/custom-theme';
 import { RootState } from 'store/store';
 import { LoginForm } from 'views-components/login-form/login-form';
-import Axios from 'axios';
+import Axios, { AxiosResponse } from 'axios';
 import { Config } from 'common/config';
 import { sanitizeHTML } from 'common/html-sanitize';
 
@@ -51,11 +51,17 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     }
 });
 
+export type PasswordLoginResponse = {
+    uuid?: string;
+    api_token?: string;
+    message?: string;
+};
+
 const doPasswordLogin = (url: string) => (username: string, password: string) => {
     const formData: string[] = [];
     formData.push('username='+encodeURIComponent(username));
     formData.push('password='+encodeURIComponent(password));
-    return Axios.post(`${url}/arvados/v1/users/authenticate`, formData.join('&'), {
+    return Axios.post<string, AxiosResponse<PasswordLoginResponse>>(`${url}/arvados/v1/users/authenticate`, formData.join('&'), {
         headers: {
             'Content-Type': 'application/x-www-form-urlencoded'
         },