diff --git a/Accounts/src/Pages/Login.tsx b/Accounts/src/Pages/Login.tsx index 2a942547e64..cfc090a88af 100644 --- a/Accounts/src/Pages/Login.tsx +++ b/Accounts/src/Pages/Login.tsx @@ -79,20 +79,29 @@ const LoginPage: () => JSX.Element = () => { src={OneUptimeLogo} alt="OneUptime" /> - {!showTwoFactorAuth && <>

- Sign in to your account -

-

- Join thousands of business that use OneUptime to help them stay online - all the time. -

} + {!showTwoFactorAuth && ( + <> +

+ Sign in to your account +

+

+ Join thousands of business that use OneUptime to help them stay + online all the time. +

+ + )} - {showTwoFactorAuth && <>

- Two Factor Authentication -

-

- Select two factor authentication method. You will be asked to enter a code from the selected method. -

} + {showTwoFactorAuth && ( + <> +

+ Two Factor Authentication +

+

+ Select two factor authentication method. You will be asked to + enter a code from the selected method. +

+ + )}
@@ -143,10 +152,15 @@ const LoginPage: () => JSX.Element = () => { value: User | JSONObject, miscData: JSONObject | undefined, ) => { - if ((miscData as JSONObject)["twoFactorAuth"] === true) { + if ( + miscData && + (miscData as JSONObject)["twoFactorAuth"] === true + ) { const twoFactorAuthList: Array = UserTwoFactorAuth.fromJSONArray( - (miscData as JSONObject)["twoFactorAuthList"] as JSONArray, + (miscData as JSONObject)[ + "twoFactorAuthList" + ] as JSONArray, UserTwoFactorAuth, ); setTwoFactorAuthList(twoFactorAuthList); @@ -196,7 +210,7 @@ const LoginPage: () => JSX.Element = () => { description: "Enter the code from your authenticator app", required: true, dataTestId: "code", - fieldType: FormFieldSchemaType.Text + fieldType: FormFieldSchemaType.Text, }, ]} submitButtonText={"Login"} @@ -208,7 +222,8 @@ const LoginPage: () => JSX.Element = () => { try { const code: string = data["code"] as string; - const twoFactorAuthId: string = selectedTwoFactorAuth.id?.toString() as string; + const twoFactorAuthId: string = + selectedTwoFactorAuth.id?.toString() as string; const result: HTTPErrorResponse | HTTPResponse = await API.post(VERIFY_TWO_FACTOR_AUTH_API_URL, { @@ -242,24 +257,31 @@ const LoginPage: () => JSX.Element = () => { )}
- {!selectedTwoFactorAuth &&
- Don't have an account?{" "} - - Register. - -
} - {selectedTwoFactorAuth ?
- { - setSelectedTwoFactorAuth(undefined); - }} - className="text-indigo-500 hover:text-indigo-900 cursor-pointer" - > - Select a different two factor authentication method -
: <>} + {!selectedTwoFactorAuth && ( +
+ Don't have an account?{" "} + + Register. + +
+ )} + {selectedTwoFactorAuth ? ( +
+ { + setSelectedTwoFactorAuth(undefined); + }} + className="text-indigo-500 hover:text-indigo-900 cursor-pointer" + > + Select a different two factor authentication method + +
+ ) : ( + <> + )}
diff --git a/App/FeatureSet/Identity/API/Authentication.ts b/App/FeatureSet/Identity/API/Authentication.ts index a58c49b527c..e32dab49c5c 100644 --- a/App/FeatureSet/Identity/API/Authentication.ts +++ b/App/FeatureSet/Identity/API/Authentication.ts @@ -632,7 +632,9 @@ const login: LoginFunction = async (options: { return Response.sendErrorResponse( req, res, - new BadDataException("Invalid login: Email or password does not match."), + new BadDataException( + "Invalid login: Email or password does not match.", + ), ); } @@ -654,14 +656,16 @@ const login: LoginFunction = async (options: { ); } - return Response.sendEntityResponse( - req, res, user, User, { - miscData: { - twoFactorAuthList: UserTwoFactorAuth.toJSONArray(twoFactorAuthList, UserTwoFactorAuth), - twoFactorAuth: true - }, - }); - } + return Response.sendEntityResponse(req, res, user, User, { + miscData: { + twoFactorAuthList: UserTwoFactorAuth.toJSONArray( + twoFactorAuthList, + UserTwoFactorAuth, + ), + twoFactorAuth: true, + }, + }); + } if (verifyTwoFactorAuth) { // code from req diff --git a/CommonServer/Services/UserTwoFactorAuthService.ts b/CommonServer/Services/UserTwoFactorAuthService.ts index 9eb0056412d..8461560bc5a 100644 --- a/CommonServer/Services/UserTwoFactorAuthService.ts +++ b/CommonServer/Services/UserTwoFactorAuthService.ts @@ -58,7 +58,6 @@ export class Service extends DatabaseService { protected override async onBeforeDelete( deleteBy: DeleteBy, ): Promise> { - const itemsToBeDeleted: Array = await this.findBy({ query: deleteBy.query, select: {