diff --git a/frontend/app/components/ForgotPassword/ResetPasswordRequest.tsx b/frontend/app/components/ForgotPassword/ResetPasswordRequest.tsx index f8093e1f4..b95ecf5e1 100644 --- a/frontend/app/components/ForgotPassword/ResetPasswordRequest.tsx +++ b/frontend/app/components/ForgotPassword/ResetPasswordRequest.tsx @@ -1,8 +1,9 @@ import React from 'react'; -import { Form, Input, Loader, Button, Icon } from 'UI'; +import { Loader, Icon } from 'UI'; import ReCAPTCHA from 'react-google-recaptcha'; import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; +import {Form, Input, Button } from 'antd' function ResetPasswordRequest() { const { userStore } = useStore(); @@ -20,8 +21,8 @@ function ResetPasswordRequest() { if (name === 'email') setEmail(value); }; - const onSubmit = (e: any) => { - e.preventDefault(); + const onSubmit = () => { + // e.preventDefault(); if (CAPTCHA_ENABLED && recaptchaRef.current) { recaptchaRef.current.execute(); } else if (!CAPTCHA_ENABLED) { @@ -30,19 +31,21 @@ function ResetPasswordRequest() { }; const handleSubmit = (token?: any) => { - if (CAPTCHA_ENABLED && recaptchaRef.current && (token === null || token === undefined)) return; + if (CAPTCHA_ENABLED && recaptchaRef.current && (token === null || token === undefined)) return; setError(null); requestResetPassword({ email: email.trim(), 'g-recaptcha-response': token }) .then((response: any) => { setRequested(true); - if (response && response.errors && response.errors.length > 0) { - setError(response.errors[0]); - } - }); + // if (response && response.errors && response.errors.length > 0) { + // setError(response.errors[0]); + // } + }).catch((err: any) => { + setRequested(false); + }); }; return ( -
+ {CAPTCHA_ENABLED && (
@@ -57,7 +60,7 @@ function ResetPasswordRequest() { )} {!requested && ( <> - + } required /> - - @@ -89,14 +92,14 @@ function ResetPasswordRequest() {
)} - {error && ( -
-
- -
- {error} -
- )} + {/*{error && (*/} + {/*
*/} + {/*
*/} + {/* */} + {/*
*/} + {/* {error}*/} + {/*
*/} + {/*)}*/}
); diff --git a/frontend/app/components/Login/Login.tsx b/frontend/app/components/Login/Login.tsx index 990e771e9..559f1bd9c 100644 --- a/frontend/app/components/Login/Login.tsx +++ b/frontend/app/components/Login/Login.tsx @@ -10,7 +10,8 @@ import { toast } from 'react-toastify'; import { ENTERPRISE_REQUEIRED } from 'App/constants'; import { useStore } from 'App/mstore'; import { forgotPassword, signup } from 'App/routes'; -import { Button, Form, Icon, Input, Link, Loader, Tooltip } from 'UI'; +import { Icon, Link, Loader, Tooltip } from 'UI'; +import { Button, Form, Input } from 'antd'; import Copyright from 'Shared/Copyright'; @@ -24,12 +25,12 @@ interface LoginProps { } const Login = ({ - location, -}: LoginProps) => { + location + }: LoginProps) => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const CAPTCHA_ENABLED = React.useMemo(() => { - return window.env.CAPTCHA_ENABLED === 'true' + return window.env.CAPTCHA_ENABLED === 'true'; }, []); const recaptchaRef = useRef(null); const { loginStore, userStore } = useStore(); @@ -41,9 +42,9 @@ const Login = ({ const params = new URLSearchParams(location.search); useEffect(() => { - if (authDetails && !authDetails.tenants) { - history.push(SIGNUP_ROUTE); - } + if (authDetails && !authDetails.tenants) { + history.push(SIGNUP_ROUTE); + } }, [authDetails]); useEffect(() => { @@ -83,7 +84,7 @@ const Login = ({ window.postMessage( { type: 'orspot:token', - token: jwt, + token: jwt }, '*' ); @@ -104,7 +105,7 @@ const Login = ({ .generateJWT() .then((resp) => { if (resp) { - userStore.syntheticLogin(resp) + userStore.syntheticLogin(resp); setJwt({ jwt: resp.jwt, spotJwt: resp.spotJwt ?? null }); handleSpotLogin(resp.spotJwt); } @@ -114,8 +115,7 @@ const Login = ({ }); }; - const onSubmit = (e: React.FormEvent) => { - e.preventDefault(); + const onSubmit = () => { if (CAPTCHA_ENABLED && recaptchaRef.current) { recaptchaRef.current.execute(); } else if (!CAPTCHA_ENABLED) { @@ -140,7 +140,7 @@ const Login = ({
@@ -154,7 +154,7 @@ const Login = ({ /> )}
- + setEmail(e.target.value)} required - icon="envelope" + prefix={} /> - - + + setPassword(e.target.value)} required - icon="key" + prefix={} /> - +
{errors && errors.length ? ( @@ -201,8 +201,8 @@ const Login = ({ @@ -221,7 +221,7 @@ const Login = ({
{authDetails.sso ? ( -
- diff --git a/frontend/app/mstore/userStore.ts b/frontend/app/mstore/userStore.ts index 617323bbb..a5cba59b5 100644 --- a/frontend/app/mstore/userStore.ts +++ b/frontend/app/mstore/userStore.ts @@ -399,21 +399,18 @@ class UserStore { }; requestResetPassword = async (params: any) => { - runInAction(() => { - this.loading = true; - }); + this.loading = true; try { - const response = await userService.requestResetPassword(params); - if (response.errors) { - toast.error(response.errors[0] || 'Error resetting your password, please try again'); - return response; - } + await userService.requestResetPassword(params); + // if (response.errors) { + // toast.error(response.errors[0] || 'Error resetting your password, please try again'); + // return response; + // } } catch (error) { - toast.error('Unexpected error resetting your password; please try again'); + toast.error(error.message || 'Unexpected error resetting your password; please try again'); + throw error; } finally { - runInAction(() => { this.loading = false; - }); } }; diff --git a/frontend/app/services/UserService.ts b/frontend/app/services/UserService.ts index 1dabe0e00..4b2d47744 100644 --- a/frontend/app/services/UserService.ts +++ b/frontend/app/services/UserService.ts @@ -156,17 +156,9 @@ export default class UserService { } async requestResetPassword(data: any) { - try { - const response = await this.client.post('/password/reset-link', data); - const responseData = await response.json(); - return responseData.data || {}; - } catch (error: any) { - if (error.response) { - const errorData = await error.response.json(); - return { errors: errorData.errors }; - } - return { errors: ['An unexpected error occurred.'] }; - } + const response = await this.client.post('/password/reset-link', data); + const responseData = await response.json(); + return responseData.data || {}; } updatePassword = async (data: any) => { diff --git a/frontend/app/services/loginService.ts b/frontend/app/services/loginService.ts index 7b7e74852..6087082f3 100644 --- a/frontend/app/services/loginService.ts +++ b/frontend/app/services/loginService.ts @@ -6,27 +6,18 @@ export default class LoginService extends BaseService { password: string, captchaResponse?: string }) { - try { - const response = await this.client.post('/login', { - email: email.trim(), - password, - 'g-recaptcha-response': captchaResponse - }); + const response = await this.client.post('/login', { + email: email.trim(), + password, + 'g-recaptcha-response': captchaResponse + }); - const responseData = await response.json(); + const responseData = await response.json(); - if (responseData.errors) { - throw new Error(responseData.errors[0] || 'An unexpected error occurred.'); - } + // if (responseData.errors) { + // throw new Error(responseData.errors[0] || 'An unexpected error occurred.'); + // } - return responseData || {}; - } catch (error: any) { - if (error.response) { - const errorData = await error.response.json(); - const errorMessage = errorData.errors ? errorData.errors[0] : 'An unexpected error occurred.'; - throw new Error(errorMessage); - } - throw new Error('An unexpected error occurred.'); - } + return responseData || {}; } }