Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-1678]:Fix/Update wrong login credentials text #1300

Open
wants to merge 3 commits into
base: release/2.7.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/auth/components/LogIn/LogIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default function LogIn(): JSX.Element {
navigationService.history.push(`/activate/${email}`);
}

setLoginError([castedError.message]);
setLoginError([(err as AppError)?.status === 401 ? translate('auth.login.wrongLogin') : castedError.message]);
Copy link
Contributor

@masterprog-cmd masterprog-cmd Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can extract this conditional out of the setState. E.g.:

const UNAUTHORIZED_STATUS_CODE = 401;

function getLoginErrorMessage(err: unknown): string {
  const appError = err as AppError;
  if (appError?.status === UNAUTHORIZED_STATUS_CODE) {
    return translate('auth.login.wrongLogin');
  }
  return appError?.message || 'An unexpected error occurred';
}

setLoginError([getLoginErrorMessage(err)])

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Done!

setShowErrors(true);
if ((err as AppError)?.status === 403) {
await sendUnblockAccountEmail(email);
Expand Down
4 changes: 2 additions & 2 deletions src/app/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { generateMnemonic, validateMnemonic } from 'bip39';
import { SdkFactory } from '../../core/factory/sdk';
import httpService from '../../core/services/http.service';
import navigationService from 'app/core/services/navigation.service';
import { AppView } from 'app/core/types';
import AppError, { AppView } from 'app/core/types';

export async function logOut(loginParams?: Record<string, string>): Promise<void> {
analyticsService.trackSignOut();
Expand All @@ -55,7 +55,7 @@ export const is2FANeeded = async (email: string): Promise<boolean> => {
const authClient = SdkFactory.getInstance().createAuthClient();
const securityDetails = await authClient.securityDetails(email).catch((error) => {
analyticsService.signInAttempted(email, error.message);
throw new Error(error.message ?? 'Login error');
throw new AppError(error.message ?? 'Login error', error.status ?? 500);
});

return securityDetails.tfaEnabled;
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"dontHaveAccount": "Sie haben kein Konto?",
"createAccount": "Konto erstellen",
"2FA": "Zwei-Faktor-Code",
"twoFactorAuthenticationCode": "Zwei-Faktor-Authentifizierungscode"
"twoFactorAuthenticationCode": "Zwei-Faktor-Authentifizierungscode",
"wrongLogin": "Ungültiger Benutzername oder Passwort"
},
"signup": {
"title": "Konto erstellen",
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"dontHaveAccount": "Don't have an account?",
"createAccount": "Create account",
"2FA": "Two factor code",
"twoFactorAuthenticationCode": "Two factor authentication code"
"twoFactorAuthenticationCode": "Two factor authentication code",
"wrongLogin": "Invalid username or password"
},
"signup": {
"title": "Create account",
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"dontHaveAccount": "¿No tienes cuenta?",
"createAccount": "Crear cuenta",
"2FA": "Código de dos factores",
"twoFactorAuthenticationCode": "Código de autenticación de dos factores"
"twoFactorAuthenticationCode": "Código de autenticación de dos factores",
"wrongLogin": "Nombre de usuario o contraseña no válidos"
},
"signup": {
"title": "Crear cuenta",
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"dontHaveAccount": "Vous n'avez pas de compte ?",
"createAccount": "Créer un compte",
"2FA": "Code à deux facteurs",
"twoFactorAuthenticationCode": "Code d'authentification à deux facteurs"
"twoFactorAuthenticationCode": "Code d'authentification à deux facteurs",
"wrongLogin": "Nom d'utilisateur ou mot de passe invalide"
},
"signup": {
"title": "Créer un compte",
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"dontHaveAccount": "Non hai un account?",
"createAccount": "Creare un account",
"2FA": "Codice a due fattori",
"twoFactorAuthenticationCode": "Codice di autenticazione a due fattori"
"twoFactorAuthenticationCode": "Codice di autenticazione a due fattori",
"wrongLogin": "Nome utente o password non validi"
},
"signup": {
"title": "Creare un account",
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"dontHaveAccount": "У вас нет учетной записи?",
"createAccount": "Создать учетную запись",
"2FA": "Двухфакторный код",
"twoFactorAuthenticationCode": "Код двухфакторной аутентификации"
"twoFactorAuthenticationCode": "Код двухфакторной аутентификации",
"wrongLogin": "Неверное имя пользователя или пароль"
},
"signup": {
"title": "Создать учетную запись",
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"dontHaveAccount": "沒有帳戶?",
"createAccount": "創建帳戶",
"2FA": "雙重身份驗證代碼",
"twoFactorAuthenticationCode": "雙重身份驗證代碼"
"twoFactorAuthenticationCode": "雙重身份驗證代碼",
"wrongLogin": "使用者名稱或密碼無效"
},
"signup": {
"title": "創建帳戶",
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"dontHaveAccount": "没有账户?",
"createAccount": "创建账户",
"2FA": "双因素代码",
"twoFactorAuthenticationCode": "双因素验证码"
"twoFactorAuthenticationCode": "双因素验证码",
"wrongLogin": "用户名或密码无效"
},
"signup": {
"title": "创建账户",
Expand Down
Loading