diff --git a/src/IsaacAppTypes.tsx b/src/IsaacAppTypes.tsx index 96833945e2..0dc7f1c413 100644 --- a/src/IsaacAppTypes.tsx +++ b/src/IsaacAppTypes.tsx @@ -705,7 +705,6 @@ export interface AdditionalInformation { export interface CredentialsAuthDTO { email: string; password: string; - rememberMe: boolean; } export interface PaddedCredentialsAuthDTO extends CredentialsAuthDTO { diff --git a/src/app/components/elements/modals/LoginOrSignUpModal.tsx b/src/app/components/elements/modals/LoginOrSignUpModal.tsx index 68240d52d4..42db706949 100644 --- a/src/app/components/elements/modals/LoginOrSignUpModal.tsx +++ b/src/app/components/elements/modals/LoginOrSignUpModal.tsx @@ -1,5 +1,5 @@ import React, { useEffect } from "react"; -import { Button, Col, CustomInput, Form, Row } from "reactstrap"; +import { Button, Col, Form, Row } from "reactstrap"; import { closeActiveModal, selectors, store, useAppDispatch, useAppSelector } from "../../../state"; import { useLocation } from "react-router-dom"; import { @@ -20,14 +20,13 @@ const LoginOrSignUpBody = () => { const { loginFunctions, setStateFunctions, loginValues } = useLoginLogic(); const { attemptLogIn, signUp, validateAndLogIn } = loginFunctions; - const { setEmail, setPassword, setRememberMe, setPasswordResetAttempted } = setStateFunctions; + const { setEmail, setPassword, setPasswordResetAttempted } = setStateFunctions; const { email, totpChallengePending, errorMessage, logInAttempted, passwordResetAttempted, - rememberMe, isValidEmail, isValidPassword, } = loginValues; @@ -84,7 +83,7 @@ const LoginOrSignUpBody = () => { )}
{totpChallengePending ? ( - + ) : ( <> { small /> - setRememberMe(e.target.checked)} - /> + /> */}

{errorMessage} diff --git a/src/app/components/pages/LogIn.tsx b/src/app/components/pages/LogIn.tsx index ebdf91339a..219f4a7567 100644 --- a/src/app/components/pages/LogIn.tsx +++ b/src/app/components/pages/LogIn.tsx @@ -15,7 +15,6 @@ import { CardBody, Col, Container, - CustomInput, Form, FormFeedback, FormGroup, @@ -42,7 +41,6 @@ export const useLoginLogic = () => { const errorMessage = useAppSelector(selectors.error.general); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); - const [rememberMe, setRememberMe] = useState(false); const [logInAttempted, setLoginAttempted] = useState(false); const isValidEmail = email.length > 0 && email.includes("@"); @@ -54,7 +52,7 @@ export const useLoginLogic = () => { event.preventDefault(); // Password check here will have to remain on old requirements as existing accounts will not be able to log in otherwise if (password.length > 6 && isValidEmail) { - dispatch(logInUser("SEGUE", { email: email, password: password, rememberMe: rememberMe })); + dispatch(logInUser("SEGUE", { email: email, password: password })); } }; @@ -69,14 +67,13 @@ export const useLoginLogic = () => { return { loginFunctions: { attemptLogIn, signUp, validateAndLogIn }, - setStateFunctions: { setEmail, setPassword, setRememberMe, setPasswordResetAttempted }, + setStateFunctions: { setEmail, setPassword, setPasswordResetAttempted }, loginValues: { email, totpChallengePending, errorMessage, logInAttempted, passwordResetAttempted, - rememberMe, isValidEmail, isValidPassword, }, @@ -99,10 +96,7 @@ export const GoogleSignInButton = () => { }; // Handles display and logic of the two-factor authentication form (usually shown after the first login step) -export const TFAInput = React.forwardRef(function TFAForm( - { rememberMe }: { rememberMe: boolean }, - ref: React.Ref, -) { +export const TFAInput = React.forwardRef(function TFAForm(_props, ref) { const dispatch = useAppDispatch(); const [mfaVerificationCode, setMfaVerificationCode] = useState(""); @@ -139,7 +133,7 @@ export const TFAInput = React.forwardRef(function TFAForm( disabled={isNaN(Number(mfaVerificationCode))} onClick={(event) => { event.preventDefault(); - if (mfaVerificationCode) dispatch(submitTotpChallengeResponse(mfaVerificationCode, rememberMe)); + if (mfaVerificationCode) dispatch(submitTotpChallengeResponse(mfaVerificationCode)); }} /> @@ -255,14 +249,13 @@ export const LogIn = () => { const { loginFunctions, setStateFunctions, loginValues } = useLoginLogic(); const { attemptLogIn, signUp, validateAndLogIn } = loginFunctions; - const { setEmail, setPassword, setRememberMe, setPasswordResetAttempted } = setStateFunctions; + const { setEmail, setPassword, setPasswordResetAttempted } = setStateFunctions; const { email, totpChallengePending, errorMessage, logInAttempted, passwordResetAttempted, - rememberMe, isValidEmail, isValidPassword, } = loginValues; @@ -311,7 +304,7 @@ export const LogIn = () => { Log in or sign up:

{totpChallengePending ? ( - + ) : ( { /> - - setRememberMe(e.target.checked)} - /> -

diff --git a/src/app/services/api.ts b/src/app/services/api.ts index 3c09e05fbb..7787084566 100644 --- a/src/app/services/api.ts +++ b/src/app/services/api.ts @@ -155,8 +155,8 @@ export const api = { ): AxiosPromise => { return endpoint.post(`/auth/${provider}/authenticate`, securePadCredentials(credentials)); }, - mfaCompleteLogin: (mfaVerificationCode: string, rememberMe: boolean): AxiosPromise => { - return endpoint.post(`/auth/mfa/challenge`, { mfaVerificationCode: mfaVerificationCode, rememberMe }); + mfaCompleteLogin: (mfaVerificationCode: string): AxiosPromise => { + return endpoint.post(`/auth/mfa/challenge`, { mfaVerificationCode: mfaVerificationCode }); }, getCurrentUserAuthSettings: (): AxiosPromise => { return endpoint.get(`/auth/user_authentication_settings`); diff --git a/src/app/state/actions/index.tsx b/src/app/state/actions/index.tsx index 3a1ecc9827..2e6e2945f7 100644 --- a/src/app/state/actions/index.tsx +++ b/src/app/state/actions/index.tsx @@ -169,21 +169,20 @@ export const unlinkAccount = (provider: AuthenticationProvider) => async (dispat } }; -export const submitTotpChallengeResponse = - (mfaVerificationCode: string, rememberMe: boolean) => async (dispatch: Dispatch) => { - dispatch({ type: ACTION_TYPE.USER_AUTH_MFA_CHALLENGE_REQUEST }); - try { - const result = await api.authentication.mfaCompleteLogin(mfaVerificationCode, rememberMe); - // Request user preferences, as we do in the requestCurrentUser action: - await Promise.all([dispatch(getUserAuthSettings() as any), dispatch(getUserPreferences() as any)]); - dispatch({ type: ACTION_TYPE.USER_AUTH_MFA_CHALLENGE_SUCCESS }); - dispatch({ type: ACTION_TYPE.USER_LOG_IN_RESPONSE_SUCCESS, user: result.data }); - history.replace(persistence.pop(KEY.AFTER_AUTH_PATH) || "/"); - } catch (e: any) { - dispatch({ type: ACTION_TYPE.USER_AUTH_MFA_CHALLENGE_FAILURE, errorMessage: extractMessage(e) }); - dispatch(showAxiosErrorToastIfNeeded("Error with verification code.", e)); - } - }; +export const submitTotpChallengeResponse = (mfaVerificationCode: string) => async (dispatch: Dispatch) => { + dispatch({ type: ACTION_TYPE.USER_AUTH_MFA_CHALLENGE_REQUEST }); + try { + const result = await api.authentication.mfaCompleteLogin(mfaVerificationCode); + // Request user preferences, as we do in the requestCurrentUser action: + await Promise.all([dispatch(getUserAuthSettings() as any), dispatch(getUserPreferences() as any)]); + dispatch({ type: ACTION_TYPE.USER_AUTH_MFA_CHALLENGE_SUCCESS }); + dispatch({ type: ACTION_TYPE.USER_LOG_IN_RESPONSE_SUCCESS, user: result.data }); + history.replace(persistence.pop(KEY.AFTER_AUTH_PATH) || "/"); + } catch (e: any) { + dispatch({ type: ACTION_TYPE.USER_AUTH_MFA_CHALLENGE_FAILURE, errorMessage: extractMessage(e) }); + dispatch(showAxiosErrorToastIfNeeded("Error with verification code.", e)); + } +}; export const getUserPreferences = () => async (dispatch: Dispatch) => { dispatch({ type: ACTION_TYPE.USER_PREFERENCES_REQUEST });