-
+
);
};
diff --git a/src/main/Mobile/Pages/Login/Login.module.css b/src/main/Mobile/Pages/Login/Login.module.css
index ad4d5a2..a383f98 100644
--- a/src/main/Mobile/Pages/Login/Login.module.css
+++ b/src/main/Mobile/Pages/Login/Login.module.css
@@ -3,30 +3,12 @@
background-repeat: repeat;
background-position: center center;
background-size: 600px 1200px;
- /*background-color: var(--mainContent);*/
background-color: var(--container);
color: var(--textColor);
}
-.row {
- height: 100vh;
-}
-.intro {
- height: 100vh;
- background-repeat: no-repeat repeat;
- background-position: center center;
- background-size: 600px 1200px;
-}
-.intro img {
- width: 45vw;
-}
-.intro h1 {
- line-height: 4.5vh;
- text-align: center;
- /*color: #f2f2f2;*/
-}
+
.content {
- width: 80%;
- /*height: 65%;*/
+ width: 90%;
background-color: var(--cardBodyAlpha);
border-radius: 9px;
color: var(--textColor);
@@ -35,52 +17,49 @@
.content :global(.accordion-header) > div{
justify-content: center;
+ margin-top: 1.5vh;
}
.content :global(.accordion-header){
- /*background-color: #242633fa;*/
background-color: var(--cardHeaderAlpha);
- /*color: #ecececc7;*/
}
-/*.content :global(.accordion-body){
- background-color: rgba(206, 223, 255, 0.83);
-}*/
+
.forgetPasswordInput{
width: 75%;
}
.loginInput {
- width: 85%;
- margin-bottom: 1vh;
+ width: 93%;
+ margin-bottom: 2vh;
}
.loginInput > div{
border-color: var(--cardHeader);
}
.loginInput :global(.lead){
- /*background-color: #242633fa;
- border-color: #242633fa;
- color: #ecececc7;*/
background-color: var(--cardHeader);
border-color: var(--cardHeader);
color: var(--textColor);
+ width: 40%;
}
-.loginInput.captcha :global(.lead){
- width: 50%;
-
+.loginInput :global(input){
+ width: 60% !important;
}
-.loginInput.captcha :global(.lead) span{
- width: 100%;
- height: 100%;
- background-position: center;
- background-repeat: no-repeat;
- /*background-size: cover;*/
+
+
+
+
+.loginInput.captcha :global(.lead){
+ width: 40%;
}
+
.loginInput.captcha :global(input){
- width: 40%;
+ width: 43% !important;
}
+
+
.loginInput.captcha :global(.after){
- width: 10%;
+ width: 17%;
}
.thisLoading{
@@ -139,10 +118,41 @@
background-color: var(--red);
}
+.disable:disabled,.button[disabled] {
+ border: 0.3vh solid var(--cardHeader);
+ background: var(--cardHeader);
+ color: var(--textColor);
+ cursor: not-allowed;
+}
+
+.thisButton:disabled,.button[disabled] {
+ border: 0.3vh solid var(--cardHeader);
+ background: var(--cardHeader);
+ color: var(--textColor);
+ cursor: not-allowed;
+}
+
+
+
+
+
+.loginInput.passwordInput :global(.before){
+ width: 40% !important;
+}
+
+.loginInput.passwordInput :global(input){
+ width: 43% !important;
+}
+.loginInput.passwordInput :global(.after){
+ width: 17% !important;
+}
+
+
.ltrInput :global(input) {
direction: ltr !important;
}
+
.twinkle{
-webkit-animation: twinkle 4s linear infinite;
-moz-animation: twinkle 4s linear infinite;
diff --git a/src/main/Mobile/Pages/Login/api/auth.js b/src/main/Mobile/Pages/Login/api/auth.js
deleted file mode 100644
index 8c054b9..0000000
--- a/src/main/Mobile/Pages/Login/api/auth.js
+++ /dev/null
@@ -1,148 +0,0 @@
-import axios from "axios";
-
-const clientSecret = window.env.REACT_APP_CLIENT_SECRET
-const clientId = window.env.REACT_APP_CLIENT_ID
-
-
-export const getToken = async () => {
- const params = new URLSearchParams();
- params.append('client_id', clientId);
- params.append('client_secret', clientSecret);
- params.append('grant_type', 'client_credentials');
- return await axios.post('/auth/realms/opex/protocol/openid-connect/token', params)
- .then((res) => {
- return res.data.access_token;
- }).catch((e) => {
- if (!e.response) {
- return false;
- }
- return e.response;
- })
-}
-
-export const login = async (credential , agent) => {
- const params = new URLSearchParams();
- params.append('client_id', clientId);
- params.append('username', credential.username);
- params.append('password', credential.password);
- params.append('otp', credential.otp);
- params.append('agent', agent);
- params.append('grant_type', 'password');
- params.append('client_secret', clientSecret);
- return await axios.post('/auth/realms/opex/protocol/openid-connect/token', params)
- .then((res) => {
- return res;
- }).catch((e) => {
- if (!e.response) {
- return false;
- }
- return e.response;
- })
-};
-
-export const logOut = () => {
- return axios.post(`/auth/realms/opex/user-management/user/logout`)
-}
-
-export const register = (user , panelToken) => {
- return axios.post('/auth/realms/opex/user-management/user', user ,{
- headers : {
- "Authorization" : "Bearer "+ panelToken
- }
- })
-}
-
-export const getCaptcha = async () => {
- return await axios.post(`/captcha/session`, null ,{
- headers : {
- 'Accept' : 'image/jpeg'
-
- },
- responseType: "arraybuffer"
- })
- .then((res) => {
- return res;
- }).catch((e) => {
- if (!e.response) {
- return false;
- }
- return e.response;
- })
-};
-
-
-//Todo Remove getUser
-export const getUser = async (token, key , value) => {
- axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
- return await axios.get(`/auth/admin/realms/opex/users?${key}=${value}`,)
- .then((res) => {
- return res;
- }).catch((e) => {
- if (!e.response) {
- return false;
- }
- return e.response;
- })
-}
-
-export const sendForgetPasswordEmail = async (panelToken , email ,captchaAnswer) => {
- return await axios.post(`/auth/realms/opex/user-management/user/forgot?email=${email}&captcha-answer=${captchaAnswer}`,null ,{
- headers : {
- "Authorization" : "Bearer "+ panelToken
- }
- }).then((res) => {
- return res;
- }).catch((e) => {
- if (!e.response) {
- return false;
- }
- return e.response;
- })
-}
-
-export const parseToken = ( data ) => {
- return {
- accessToken: data.access_token,
- accessTokenExpires: Date.now() + data.expires_in * 1000,
- refreshToken: data.refresh_token,
- refreshTokenExpires: Date.now() + data.refresh_expires_in * 1000,
- }
-}
-export const parsePanelToken = ( data ) => {
- return {
- panelAccessToken: data.access_token,
- panelAccessTokenExpires: Date.now() + data.expires_in * 1000,
- }
-}
-
-export const sendUpdateProfileReq = async (token, user, attributes ) => {
- axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
- axios.defaults.headers.common['Content-Type'] = 'application/json';
- return await axios.put(`auth/admin/realms/opex/users/${user}`,{
- attributes ,
- }).then((res) => {
- return res;
- }).catch((e) => {
- if (!e.response) {
- return false;
- }
- return e.response;
- })
-}
-
-
-
-export const addToKycGroup = async (token, userId) => {
- axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
- axios.defaults.headers.common['Content-Type'] = 'application/json';
- return await axios.put(`/auth/admin/realms/opex/users/${userId}/groups/24200655-dfef-4ed0-a8b8-925918793552`)
- .then((res) => {
- return res;
- }).catch((e) => {
- if (!e.response) {
- return false;
- }
- return e.response;
- })
-};
-
diff --git a/src/main/Mobile/Pages/Login/components/EmailVerification/EmailVerification.js b/src/main/Mobile/Pages/Login/components/EmailVerification/EmailVerification.js
new file mode 100644
index 0000000..87e68e2
--- /dev/null
+++ b/src/main/Mobile/Pages/Login/components/EmailVerification/EmailVerification.js
@@ -0,0 +1,212 @@
+import React, {useEffect, useState} from 'react';
+import classes from "../../Login.module.css";
+import Button from "../../../../../../components/Button/Button";
+import {useTranslation} from "react-i18next";
+import {getCaptchaImage, requestForVerifyEmail} from "js-api-client";
+import LoginFormLoading from "../LoginLoading/LoginFormLoading";
+import {validateEmail} from "../../../../../../utils/utils";
+import {images} from "../../../../../../assets/images";
+import TextInput from "../../../../../../components/TextInput/TextInput";
+import Icon from "../../../../../../components/Icon/Icon";
+import Countdown from "react-countdown";
+import {useDispatch, useSelector} from "react-redux";
+import {setVerifyEmailLockInitiate} from "../../../../../../store/actions";
+import {Buffer} from 'buffer';
+
+
+const EmailVerification = ({returnFunc, email, disable, returnFuncDisableFalse, returnFuncDisableTrue}) => {
+
+ const {t} = useTranslation();
+ const dispatch = useDispatch();
+
+ const [loading, setLoading] = useState(false);
+ const [isLoading, setIsLoading] = useState(true);
+ const [success, setSuccess] = useState(false);
+
+ const verifyEmailLock = useSelector((state) => state.exchange.verifyEmailLock)
+
+ const [activeEmail, setActiveEmail] = useState({
+ email: {value: "", error: []},
+ captchaAnswer: {value: "", error: []},
+ });
+ const [captcha, setCaptcha] = useState({
+ image: {value: "", error: []},
+ SessionKey: {value: "", error: []},
+ expireTime: {value: "", error: []},
+ });
+
+ const captchaReq = () => {
+ setIsLoading(true)
+ getCaptchaImage()
+ .then((res) => {
+ setCaptcha({
+ image: {
+ value: `data:${res.headers['content-type']};base64,${Buffer.from(res.data).toString('base64')}`,
+ error: []
+ },
+ SessionKey: {value: res.headers['captcha-session-key'], error: []},
+ expireTime: {value: res.headers['captcha-expire-timestamp'], error: []},
+ })
+ }).catch(() => {
+ setActiveEmail({...activeEmail, captchaAnswer: {value: "", error: [t("login.captchaServerError")]}})
+ setCaptcha({...captcha, image: {value: undefined, error: []}})
+ }).finally(() => {
+ setIsLoading(false)
+ });
+ }
+
+ useEffect(() => {
+ captchaReq()
+ if (email.length > 0) return setActiveEmail({...activeEmail, email: {...activeEmail.email, value: email}})
+ }, [])
+
+
+
+
+ if (loading) return
+
+ const submit = async (e) => {
+ e.preventDefault();
+ if (activeEmail.email.value === "") {
+ setActiveEmail({...activeEmail, email: {value: "", error: [t('login.emptyEmail')]}})
+ return;
+ }
+ if (!validateEmail(activeEmail.email.value)) {
+ setActiveEmail({...activeEmail, email: {value: "", error: [t('login.forgetPassEmailForgetError')]}})
+ return;
+ }
+ if (activeEmail.captchaAnswer.value === "") {
+ setActiveEmail({...activeEmail, captchaAnswer: {value: "", error: [t('login.emptyCaptcha')]}})
+ return;
+ }
+ if (activeEmail.captchaAnswer.value.length < 5) {
+ setActiveEmail({...activeEmail, captchaAnswer: {value: "", error: [t('login.minCaptcha')]}})
+ return;
+ }
+ setLoading(true);
+
+ const captchaValue = `${captcha.SessionKey.value}-${activeEmail.captchaAnswer.value}`
+ requestForVerifyEmail(activeEmail.email.value, captchaValue)
+ .then(() => {
+ setSuccess(true)
+ returnFuncDisableTrue()
+ dispatch(setVerifyEmailLockInitiate(new Date().getTime() + 2 * 60 * 1000))
+ })
+ .catch((err) => {
+ if (err?.response?.data?.code === 10001 && err?.response?.data?.message === "Captcha is not valid") {
+ return setActiveEmail({...activeEmail, captchaAnswer: {value: "", error: [t("login.InvalidCaptcha")]}})
+ }
+ if (err?.response?.data?.code === 1002 && err?.response?.data?.message === "User already verified") {
+ return setActiveEmail({...activeEmail, captchaAnswer: {value: "", error: [t("login.emailAlreadyVerified")]}})
+ } else {
+ return setActiveEmail({
+ ...activeEmail,
+ captchaAnswer: {value: "", error: [t('login.verifyEmailServerError')]}
+ })
+ }
+ })
+ .finally(() => {
+ setLoading(false);
+ });
+
+ }
+
+ const LeadCaptchaHandler = () => {
+ if (isLoading) return

+
+ if (captcha.image.value === undefined) return
{t('captchaAnswer')}
+
+ return

+ }
+
+ const sendEmailButtonTitle = () => {
+ if (disable) {
+ return
{t('login.sendEmail')} ( {props.minutes}:{props.seconds}
}
+ onComplete={returnFuncDisableFalse}
+ />)
+ }
+ return
{t('login.sendEmail')}
+ }
+
+
+ const FormBody = () => {
+ if (success) return
{t('login.verifyEmailFinished')}
+
+ return <>
+
{t('login.resendVerifyEmail')}
+
+ setActiveEmail({...activeEmail, email: {value: e.target.value, error: []}})
+ }
+ alerts={activeEmail.email.error}
+ />
+ ${t("login.refreshCaptcha")}`}>}
+ type="text"
+ data-name="captchaAnswer"
+ data-type="input"
+ data-min={5}
+ customClass={`${classes.loginInput} ${classes.captcha}`}
+ value={activeEmail.captchaAnswer.value}
+ onchange={(e) =>
+ setActiveEmail({...activeEmail, captchaAnswer: {value: e.target.value, error: []}})
+ }
+ alerts={activeEmail.captchaAnswer.error}
+ maxLength="5"
+ />
+ >
+ }
+
+
+ const FormFooter = () => {
+ if (success) return
+
+ return <>
+
+
+ >
+ }
+
+ return (
+
+ );
+};
+
+export default EmailVerification;
diff --git a/src/main/Mobile/Pages/Login/components/ForgetPassword/ForgetPassword.js b/src/main/Mobile/Pages/Login/components/ForgetPassword/ForgetPassword.js
index dace50e..892c04e 100644
--- a/src/main/Mobile/Pages/Login/components/ForgetPassword/ForgetPassword.js
+++ b/src/main/Mobile/Pages/Login/components/ForgetPassword/ForgetPassword.js
@@ -1,17 +1,18 @@
import classes from "../../Login.module.css";
-import React, {Fragment, useEffect, useState} from "react";
+import React, {useEffect, useState} from "react";
import TextInput from "../../../../../../components/TextInput/TextInput";
import LoginFormLoading from "../LoginLoading/LoginFormLoading";
import {useTranslation} from "react-i18next";
-import {getCaptcha, getToken, sendForgetPasswordEmail} from "../../api/auth";
import Button from "../../../../../../components/Button/Button";
import ReactTooltip from "react-tooltip";
import Icon from "../../../../../../components/Icon/Icon";
import {images} from "../../../../../../assets/images";
import {validateEmail} from "../../../../../../utils/utils";
import {Buffer} from 'buffer';
+import {getCaptchaImage, requestForForgetPassword} from "js-api-client";
const ForgetPassword = ({returnFunc}) => {
+ const {t} = useTranslation();
const [loading, setLoading] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [success, setSuccess] = useState(false);
@@ -24,83 +25,94 @@ const ForgetPassword = ({returnFunc}) => {
SessionKey: {value: "", error: []},
expireTime: {value: "", error: []},
});
- const {t} = useTranslation();
- const captchaReq = async () => {
+
+ const captchaReq = () => {
setIsLoading(true)
- const captchaData = await getCaptcha()
- if (captchaData && captchaData.status === 200) {
- setIsLoading(false)
- setCaptcha({
- image: { value: `data:${captchaData.headers['content-type']};base64,${Buffer.from(captchaData.data).toString('base64')}`, error: []},
- SessionKey: {value: captchaData.headers['captcha-session-key'], error: []},
- expireTime: {value: captchaData.headers['captcha-expire-timestamp'], error: []},
- })
- } else {
- setForgetPass({...forgetPass , captchaAnswer: {value: "" , error: [t("login.captchaServerError")] }})
- setCaptcha({...captcha , image: {value: undefined, error: []}})
+ getCaptchaImage()
+ .then((res) => {
+ setCaptcha({
+ image: {
+ value: `data:${res.headers['content-type']};base64,${Buffer.from(res.data).toString('base64')}`,
+ error: []
+ },
+ SessionKey: {value: res.headers['captcha-session-key'], error: []},
+ expireTime: {value: res.headers['captcha-expire-timestamp'], error: []},
+ })
+ }).catch(() => {
+ setForgetPass({...forgetPass, captchaAnswer: {value: "", error: [t("login.captchaServerError")]}})
+ setCaptcha({...captcha, image: {value: undefined, error: []}})
+ }).finally(() => {
setIsLoading(false)
- }
+ });
}
- useEffect(()=>{
- captchaReq().then(() => setIsLoading(false) )
+
+ useEffect(() => {
+ captchaReq()
}, [])
+
+
+
useEffect(() => {
ReactTooltip.rebuild();
});
- if (loading) {
- return
- }
+
+ if (loading) return
+
const submit = async (e) => {
e.preventDefault();
- if (forgetPass.email.value === ""){
+ if (forgetPass.email.value === "") {
setForgetPass({...forgetPass, email: {value: "", error: [t('login.emptyEmail')]}})
- return false
+ return;
}
- if (!validateEmail(forgetPass.email.value)){
+ if (!validateEmail(forgetPass.email.value)) {
setForgetPass({...forgetPass, email: {value: "", error: [t('login.forgetPassEmailForgetError')]}})
- return false
+ return;
}
- if (forgetPass.captchaAnswer.value === ""){
+ if (forgetPass.captchaAnswer.value === "") {
setForgetPass({...forgetPass, captchaAnswer: {value: "", error: [t('login.emptyCaptcha')]}})
- return false
+ return;
}
- if (forgetPass.captchaAnswer.value.length < 5){
+ if (forgetPass.captchaAnswer.value.length < 5) {
setForgetPass({...forgetPass, captchaAnswer: {value: "", error: [t('login.minCaptcha')]}})
- return false
+ return;
}
setLoading(true);
- let panelToken = await getToken();
+
const captchaValue = `${captcha.SessionKey.value}-${forgetPass.captchaAnswer.value}`
- const submitResult = await sendForgetPasswordEmail(panelToken, forgetPass.email.value , captchaValue);
- if( submitResult.status === 204){
- setSuccess(true)
- setLoading(false);
- }
- else {
- setLoading(false);
- if (submitResult.status === 400 && submitResult.data.error === "InvalidCaptcha" ) {
- setForgetPass({...forgetPass , captchaAnswer: {value: "", error: [t("login.InvalidCaptcha")]}})
- } else {
- setForgetPass({...forgetPass, captchaAnswer: {value: "" , error: [t('login.forgetPassServerError')] }})
- }
- }
+ requestForForgetPassword(forgetPass.email.value, captchaValue)
+ .then(() => {
+ setSuccess(true)
+ })
+ .catch((err) => {
+ if (err?.status === 400 && err?.data?.error === "InvalidCaptcha") {
+ setForgetPass({...forgetPass, captchaAnswer: {value: "", error: [t("login.InvalidCaptcha")]}})
+ } else {
+ setForgetPass({
+ ...forgetPass,
+ captchaAnswer: {value: "", error: [t('login.forgetPassServerError')]}
+ })
+ }
+ })
+ .finally(() => {
+ setLoading(false);
+ });
+
}
+
+
const LeadCaptchaHandler = () => {
- if (isLoading) {
- return
- }
- if (captcha.image.value === undefined ) {
- return {t('captchaAnswer')}
- }
+ if (isLoading) return
+
+ if (captcha.image.value === undefined) return {t('captchaAnswer')}
+
return
}
const FormBody = () => {
- if (success) {
- return {t('login.forgetPasswordFinished')}
- }
- return
+ if (success) return {t('login.forgetPasswordFinished')}
+
+ return <>
{t('login.forgetPassword')}
{
alerts={forgetPass.captchaAnswer.error}
maxLength="5"
/>
-
+ >
}
const FormFooter = () => {
- if (success) {
- return
- }
- return
+
+ return <>
-
+ >
}
diff --git a/src/main/Mobile/Pages/Login/components/LoginForm/LoginForm.js b/src/main/Mobile/Pages/Login/components/LoginForm/LoginForm.js
index 30d512d..44808ce 100644
--- a/src/main/Mobile/Pages/Login/components/LoginForm/LoginForm.js
+++ b/src/main/Mobile/Pages/Login/components/LoginForm/LoginForm.js
@@ -1,5 +1,4 @@
-import {login, parseToken} from "../../api/auth";
-import {useDispatch} from "react-redux";
+import {useDispatch, useSelector} from "react-redux";
import React, {useEffect, useState} from "react";
import classes from "../../Login.module.css";
import TextInput from "../../../../../../components/TextInput/TextInput";
@@ -7,13 +6,15 @@ import LoginFormLoading from "../LoginLoading/LoginFormLoading";
import {setUserAccountInfoInitiate, setUserInfo, setUserTokensInitiate} from "../../../../../../store/actions";
import {useLocation, useNavigate} from "react-router-dom";
import {useTranslation} from "react-i18next";
-import {setKYCStatusInitiate} from "../../../../../../store/actions";
import Button from "../../../../../../components/Button/Button";
import jwtDecode from "jwt-decode";
import OTPForm from "../OTPForm/OTPForm";
import {browserName, deviceType, fullBrowserVersion} from "react-device-detect";
import {validateEmail} from "../../../../../../utils/utils";
import ForgetPassword from "../ForgetPassword/ForgetPassword";
+import {useGetKycStatus} from "../../../../../../queries";
+import Icon from "../../../../../../components/Icon/Icon";
+import {login, parseToken} from "js-api-client";
const LoginForm = () => {
@@ -21,82 +22,87 @@ const LoginForm = () => {
const navigate = useNavigate();
const dispatch = useDispatch();
const location = useLocation();
+
+ const isDevelopment = window.env.REACT_APP_ENV === "development";
+ const [isInputVisible, setIsInputVisible] = useState(false);
const [isLoading, setLoading] = useState(false);
const [loginError, setLoginError] = useState(false);
const [needOTP, setNeedOTP] = useState(undefined);
const [forgetPassword, setForgetPassword] = useState(false);
const [credential, setCredential] = useState({username: "", password: "", otp: ""});
+ const {refetch: getKycStatus} = useGetKycStatus();
+
const from = location.state?.from?.pathname || "/";
+ const isLogin = useSelector((state) => state.auth.isLogin)
- const isDevelopment = window.env.REACT_APP_ENV === "development";
- const agent = [deviceType , browserName , fullBrowserVersion]
+ const agent = [deviceType, browserName, fullBrowserVersion]
+ const clientSecret = window.env.REACT_APP_CLIENT_SECRET
+ const clientId = window.env.REACT_APP_CLIENT_ID
useEffect(() => {
- setNeedOTP(undefined)
+ if (isLogin) navigate(from, {replace: true});
+ }, [])
+ useEffect(() => {
+ setNeedOTP(undefined)
}, [credential.username])
useEffect(() => {
setLoginError(false)
}, [needOTP])
- if (forgetPassword){
- return setForgetPassword(false)}/>
- }
+ if (forgetPassword) return setForgetPassword(false)}/>
const submit = async (e) => {
e.preventDefault();
if (credential.username.length === 0 || credential.password.length === 0) {
- setLoginError(t("login.emptyCredentialError"));
- return false;
+ return setLoginError(t("login.emptyCredentialError"));
}
- if ( !validateEmail(credential.username) || credential.password.length < 4) {
- setLoginError(t("login.inputError"));
-
- return false;
+ if (!validateEmail(credential.username) || credential.password.length < 4) {
+ return setLoginError(t("login.inputError"));
}
if (needOTP && credential.otp.length < 6) {
setLoginError(t("login.otpLength"));
setLoading(false);
- return false;
+ return;
}
setLoading(true);
setLoginError(false);
- const submitResult = await login(credential , agent);
- if (!submitResult) {
- setLoginError(t("login.loginError"));
- }
- if (submitResult.status === 401) {
- setLoginError(t("login.wrongPassword"));
- }
- if (submitResult.status === 403) {
- setLoginError(t("login.wrongOTP"));
- setNeedOTP(true)
- }
+ login(credential, agent, clientId, clientSecret)
+ .then(async (res) => {
+ const userToken = parseToken(res.data);
+ const jwt = jwtDecode(userToken.accessToken)
+ await dispatch(setUserInfo(jwt));
+ await dispatch(setUserTokensInitiate(userToken));
+ await dispatch(setUserAccountInfoInitiate())
+ await getKycStatus()
+ return navigate(from, {replace: true});
+ })
+ .catch((err) => {
+ if (err?.response?.status === 401) {
+ return setLoginError(t("login.wrongPassword"));
+ }
+ if (err?.response?.status === 403) {
+ setLoginError(t("login.wrongOTP"));
+ return setNeedOTP(true)
+ }
+ if (err?.response?.status === 400 && err?.response?.data?.error_description === "Account is not fully set up") {
+ return setLoginError(t("login.accountNotActive"));
+ }
+ setLoginError(t("login.loginError"));
+ })
+ .finally(() => {
+ setLoading(false);
+ });
- if (submitResult.status === 400 && submitResult.data.error_description === "Account is not fully set up") {
- setLoginError(t("login.accountNotActive"));
- }
- if (submitResult && submitResult.status === 200) {
- const userToken = parseToken(submitResult.data);
- dispatch(setUserTokensInitiate(userToken));
- const jwt = jwtDecode(userToken.accessToken)
- dispatch(setUserInfo(jwt));
- dispatch(setKYCStatusInitiate())
- dispatch(setUserAccountInfoInitiate())
- return navigate(from, { replace: true });
- }
- setLoading(false);
};
- if (isLoading) {
- return
- }
+ if (isLoading) return
const setOTPInputHandler = (val) => {
setCredential({...credential, otp: val})
@@ -110,14 +116,7 @@ const LoginForm = () => {
return