From b26542b8016df5454a5bd56324738cca7e910b68 Mon Sep 17 00:00:00 2001 From: cpprian Date: Fri, 9 Aug 2024 11:43:16 +0200 Subject: [PATCH 1/5] add toaster Too many bad login attempts --- ...72929d6a612846acf4a5489c36a04cb57de59.json | 22 ------------------- ...ab52c14293fa64d260db812c89ed43a5a7cc8.json | 15 ------------- web/src/i18n/en/index.ts | 18 ++++++++++----- web/src/i18n/i18n-types.ts | 8 +++++++ web/src/pages/auth/Login/Login.tsx | 3 +++ 5 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 .sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json delete mode 100644 .sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json diff --git a/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json b/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json deleted file mode 100644 index ce67e42930..0000000000 --- a/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT recovery_codes FROM \"user\" WHERE id = $1", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "recovery_codes", - "type_info": "TextArray" - } - ], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [ - false - ] - }, - "hash": "0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59" -} diff --git a/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json b/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json deleted file mode 100644 index 8d314a5faa..0000000000 --- a/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE session SET expires = $1 WHERE id = $2", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Timestamp", - "Text" - ] - }, - "nullable": [] - }, - "hash": "1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8" -} diff --git a/web/src/i18n/en/index.ts b/web/src/i18n/en/index.ts index a5ed451099..77f11cc571 100644 --- a/web/src/i18n/en/index.ts +++ b/web/src/i18n/en/index.ts @@ -850,6 +850,7 @@ const en: BaseTranslation = { number: 'Expected a valid number.', minimumValue: `Minimum value of {value: number} not reached.`, maximumValue: 'Maximum value of {value: number} exceeded.', + tooManyBadLoginAttemps: `Too many bad login attempts. Please try again in few minutes.`, }, floatingErrors: { title: 'Please correct the following:', @@ -926,20 +927,24 @@ const en: BaseTranslation = { title: 'External OpenID Settings', helper: 'Here you can change general OpenID behavior in your Defguard instance.', createAccount: { - label: 'Automatically create user account when logging in for the first time through external OpenID.', - helper: 'If this option is enabled, Defguard automatically creates new accounts for users who log in for the first time using an external OpenID provider. Otherwise, the user account must first be created by an administrator.', + label: + 'Automatically create user account when logging in for the first time through external OpenID.', + helper: + 'If this option is enabled, Defguard automatically creates new accounts for users who log in for the first time using an external OpenID provider. Otherwise, the user account must first be created by an administrator.', }, }, form: { title: 'External OpenID Client Settings', - helper: 'Here you can configure the OpenID client settings with values provided by your external OpenID provider.', - custom: "Custom", + helper: + 'Here you can configure the OpenID client settings with values provided by your external OpenID provider.', + custom: 'Custom', documentation: 'Documentation', delete: 'Delete provider', labels: { provider: { label: 'Provider', - helper: 'Select your OpenID provider. You can use custom provider and fill in the base URL by yourself.', + helper: + 'Select your OpenID provider. You can use custom provider and fill in the base URL by yourself.', }, client_id: { label: 'Client ID', @@ -951,7 +956,8 @@ const en: BaseTranslation = { }, base_url: { label: 'Base URL', - helper: 'Base URL of your OpenID provider, e.g. https://accounts.google.com. Make sure to check our documentation for more information and examples.', + helper: + 'Base URL of your OpenID provider, e.g. https://accounts.google.com. Make sure to check our documentation for more information and examples.', }, }, }, diff --git a/web/src/i18n/i18n-types.ts b/web/src/i18n/i18n-types.ts index 27fd686ad4..6e674a5847 100644 --- a/web/src/i18n/i18n-types.ts +++ b/web/src/i18n/i18n-types.ts @@ -2096,6 +2096,10 @@ type RootTranslation = { * @param {number} value */ maximumValue: RequiredParams<'value'> + /** + * T​o​o​ ​m​a​n​y​ ​b​a​d​ ​l​o​g​i​n​ ​a​t​t​e​m​p​t​s​.​ ​P​l​e​a​s​e​ ​t​r​y​ ​a​g​a​i​n​ ​i​n​ ​f​e​w​ ​m​i​n​u​t​e​s​. + */ + tooManyBadLoginAttemps: string } floatingErrors: { /** @@ -6084,6 +6088,10 @@ export type TranslationFunctions = { * Maximum value of {value} exceeded. */ maximumValue: (arg: { value: number }) => LocalizedString + /** + * Too many bad login attempts. Please try again in few minutes. + */ + tooManyBadLoginAttemps: () => LocalizedString } floatingErrors: { /** diff --git a/web/src/pages/auth/Login/Login.tsx b/web/src/pages/auth/Login/Login.tsx index 6d6a46a152..47a3579d51 100644 --- a/web/src/pages/auth/Login/Login.tsx +++ b/web/src/pages/auth/Login/Login.tsx @@ -17,6 +17,7 @@ import { import { LoaderSpinner } from '../../../shared/defguard-ui/components/Layout/LoaderSpinner/LoaderSpinner'; import { useAuthStore } from '../../../shared/hooks/store/useAuthStore'; import useApi from '../../../shared/hooks/useApi'; +import { useToaster } from '../../../shared/hooks/useToaster'; import { MutationKeys } from '../../../shared/mutations'; import { patternSafeUsernameCharacters } from '../../../shared/patterns'; import { QueryKeys } from '../../../shared/queries'; @@ -37,6 +38,7 @@ export const Login = () => { openid: { getOpenIdInfo: getOpenidInfo }, }, } = useApi(); + const toaster = useToaster(); const { data: openIdInfo, isLoading: openIdLoading } = useQuery({ queryKey: [QueryKeys.FETCH_OPENID_INFO], @@ -88,6 +90,7 @@ export const Login = () => { ); } else { console.error(error); + toaster.error(LL.form.error.tooManyBadLoginAttemps()); } }, }); From eef0419cea177700673903261cd628d19ff0b346 Mon Sep 17 00:00:00 2001 From: cpprian Date: Fri, 9 Aug 2024 13:06:11 +0200 Subject: [PATCH 2/5] sqlx prepare --- ...72929d6a612846acf4a5489c36a04cb57de59.json | 22 +++++++++++++++++++ ...ab52c14293fa64d260db812c89ed43a5a7cc8.json | 15 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json create mode 100644 .sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json diff --git a/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json b/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json new file mode 100644 index 0000000000..ce67e42930 --- /dev/null +++ b/.sqlx/query-0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT recovery_codes FROM \"user\" WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recovery_codes", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false + ] + }, + "hash": "0ad599ef120ecc02b030bd1276172929d6a612846acf4a5489c36a04cb57de59" +} diff --git a/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json b/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json new file mode 100644 index 0000000000..8d314a5faa --- /dev/null +++ b/.sqlx/query-1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE session SET expires = $1 WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamp", + "Text" + ] + }, + "nullable": [] + }, + "hash": "1bb3c8ecbd6500717d639678e08ab52c14293fa64d260db812c89ed43a5a7cc8" +} From 3968b2a9aa47014709d395d25991c7ef28cd3df8 Mon Sep 17 00:00:00 2001 From: Robert Olejnik Date: Mon, 12 Aug 2024 14:07:30 +0200 Subject: [PATCH 3/5] Update web/src/i18n/en/index.ts Co-authored-by: Aleksander <170264518+t-aleksander@users.noreply.github.com> --- web/src/i18n/en/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/i18n/en/index.ts b/web/src/i18n/en/index.ts index 77f11cc571..576863248b 100644 --- a/web/src/i18n/en/index.ts +++ b/web/src/i18n/en/index.ts @@ -850,7 +850,7 @@ const en: BaseTranslation = { number: 'Expected a valid number.', minimumValue: `Minimum value of {value: number} not reached.`, maximumValue: 'Maximum value of {value: number} exceeded.', - tooManyBadLoginAttemps: `Too many bad login attempts. Please try again in few minutes.`, + tooManyBadLoginAttemps: `Too many bad login attempts. Please try again in a few minutes.`, }, floatingErrors: { title: 'Please correct the following:', From ced97e70f040ccce8909e2a4d3a970e566c35116 Mon Sep 17 00:00:00 2001 From: Cyprian <46838495+cpprian@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:31:58 +0200 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Aleksander <170264518+t-aleksander@users.noreply.github.com> --- web/src/i18n/en/index.ts | 2 +- web/src/i18n/i18n-types.ts | 4 ++-- web/src/pages/auth/Login/Login.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/i18n/en/index.ts b/web/src/i18n/en/index.ts index 576863248b..b8254aa625 100644 --- a/web/src/i18n/en/index.ts +++ b/web/src/i18n/en/index.ts @@ -850,7 +850,7 @@ const en: BaseTranslation = { number: 'Expected a valid number.', minimumValue: `Minimum value of {value: number} not reached.`, maximumValue: 'Maximum value of {value: number} exceeded.', - tooManyBadLoginAttemps: `Too many bad login attempts. Please try again in a few minutes.`, + tooManyBadLoginAttempts: `Too many bad login attempts. Please try again in a few minutes.`, }, floatingErrors: { title: 'Please correct the following:', diff --git a/web/src/i18n/i18n-types.ts b/web/src/i18n/i18n-types.ts index 6e674a5847..59fe26c9d0 100644 --- a/web/src/i18n/i18n-types.ts +++ b/web/src/i18n/i18n-types.ts @@ -2099,7 +2099,7 @@ type RootTranslation = { /** * T​o​o​ ​m​a​n​y​ ​b​a​d​ ​l​o​g​i​n​ ​a​t​t​e​m​p​t​s​.​ ​P​l​e​a​s​e​ ​t​r​y​ ​a​g​a​i​n​ ​i​n​ ​f​e​w​ ​m​i​n​u​t​e​s​. */ - tooManyBadLoginAttemps: string + tooManyBadLoginAttempts: string } floatingErrors: { /** @@ -6091,7 +6091,7 @@ export type TranslationFunctions = { /** * Too many bad login attempts. Please try again in few minutes. */ - tooManyBadLoginAttemps: () => LocalizedString + tooManyBadLoginAttempts: () => LocalizedString } floatingErrors: { /** diff --git a/web/src/pages/auth/Login/Login.tsx b/web/src/pages/auth/Login/Login.tsx index 47a3579d51..56c28aa4ed 100644 --- a/web/src/pages/auth/Login/Login.tsx +++ b/web/src/pages/auth/Login/Login.tsx @@ -90,7 +90,7 @@ export const Login = () => { ); } else { console.error(error); - toaster.error(LL.form.error.tooManyBadLoginAttemps()); + toaster.error(LL.form.error.tooManyBadLoginAttempts()); } }, }); From eb8b926a4a6ea1a6d413e5302f7b918100d098a4 Mon Sep 17 00:00:00 2001 From: cpprian Date: Mon, 12 Aug 2024 21:51:59 +0200 Subject: [PATCH 5/5] Add polish translation for tooManyBadLoginAttempts --- web/src/i18n/i18n-types.ts | 4 ++-- web/src/i18n/pl/index.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/web/src/i18n/i18n-types.ts b/web/src/i18n/i18n-types.ts index 59fe26c9d0..8971bb54f2 100644 --- a/web/src/i18n/i18n-types.ts +++ b/web/src/i18n/i18n-types.ts @@ -2097,7 +2097,7 @@ type RootTranslation = { */ maximumValue: RequiredParams<'value'> /** - * T​o​o​ ​m​a​n​y​ ​b​a​d​ ​l​o​g​i​n​ ​a​t​t​e​m​p​t​s​.​ ​P​l​e​a​s​e​ ​t​r​y​ ​a​g​a​i​n​ ​i​n​ ​f​e​w​ ​m​i​n​u​t​e​s​. + * T​o​o​ ​m​a​n​y​ ​b​a​d​ ​l​o​g​i​n​ ​a​t​t​e​m​p​t​s​.​ ​P​l​e​a​s​e​ ​t​r​y​ ​a​g​a​i​n​ ​i​n​ ​a​ ​f​e​w​ ​m​i​n​u​t​e​s​. */ tooManyBadLoginAttempts: string } @@ -6089,7 +6089,7 @@ export type TranslationFunctions = { */ maximumValue: (arg: { value: number }) => LocalizedString /** - * Too many bad login attempts. Please try again in few minutes. + * Too many bad login attempts. Please try again in a few minutes. */ tooManyBadLoginAttempts: () => LocalizedString } diff --git a/web/src/i18n/pl/index.ts b/web/src/i18n/pl/index.ts index 53484b6311..1b3cd5ffda 100644 --- a/web/src/i18n/pl/index.ts +++ b/web/src/i18n/pl/index.ts @@ -835,6 +835,8 @@ Uwaga, podane tutaj konfiguracje nie posiadają klucza prywatnego. Musisz uzupe repeat: 'Wartości się nie pokrywają.', maximumValue: 'Maksymalna wartość {value} przekroczona.', minimumValue: 'Minimalna wartość {value} nie osiągnięta.', + tooManyBadLoginAttempts: + 'Zbyt duża ilość nieprawidłowego logowania. Spróbuj ponownie za kilka minut.', number: 'Wartość musi być liczbą.', }, floatingErrors: {