From 789dcd86154b216fcd524b9c715e936893bcdb63 Mon Sep 17 00:00:00 2001 From: Livio Spring Date: Fri, 28 Jul 2023 09:09:15 +0200 Subject: [PATCH] fix: password hash update and add missing i18n (#6285) --- internal/api/ui/login/static/i18n/bg.yaml | 1 + internal/api/ui/login/static/i18n/de.yaml | 1 + internal/api/ui/login/static/i18n/en.yaml | 1 + internal/api/ui/login/static/i18n/es.yaml | 1 + internal/api/ui/login/static/i18n/fr.yaml | 1 + internal/api/ui/login/static/i18n/it.yaml | 1 + internal/api/ui/login/static/i18n/ja.yaml | 1 + internal/api/ui/login/static/i18n/mk.yaml | 1 + internal/api/ui/login/static/i18n/pl.yaml | 1 + internal/api/ui/login/static/i18n/pt.yaml | 1 + internal/api/ui/login/static/i18n/zh.yaml | 1 + internal/command/user_human_password_model.go | 3 ++- internal/query/user_password.go | 3 ++- internal/repository/user/eventstore.go | 2 +- internal/repository/user/human_password.go | 3 ++- internal/repository/user/v1.go | 1 - internal/static/i18n/bg.yaml | 4 ++++ internal/static/i18n/de.yaml | 4 ++++ internal/static/i18n/en.yaml | 4 ++++ internal/static/i18n/es.yaml | 4 ++++ internal/static/i18n/fr.yaml | 4 ++++ internal/static/i18n/it.yaml | 4 ++++ internal/static/i18n/ja.yaml | 4 ++++ internal/static/i18n/mk.yaml | 4 ++++ internal/static/i18n/pl.yaml | 4 ++++ internal/static/i18n/pt.yaml | 5 +++++ internal/static/i18n/zh.yaml | 4 ++++ 27 files changed, 63 insertions(+), 5 deletions(-) diff --git a/internal/api/ui/login/static/i18n/bg.yaml b/internal/api/ui/login/static/i18n/bg.yaml index 20b1c1084a..030e96fc2f 100644 --- a/internal/api/ui/login/static/i18n/bg.yaml +++ b/internal/api/ui/login/static/i18n/bg.yaml @@ -391,6 +391,7 @@ Errors: InvalidAndLocked: >- Паролата е невалидна и потребителят е заключен, свържете се с вашия администратор. + NotChanged: Паролата не е променена UsernameOrPassword: Invalid: Потребителското име или паролата са невалидни PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/de.yaml b/internal/api/ui/login/static/i18n/de.yaml index 9845803595..df9cf77b6b 100644 --- a/internal/api/ui/login/static/i18n/de.yaml +++ b/internal/api/ui/login/static/i18n/de.yaml @@ -399,6 +399,7 @@ Errors: Empty: Passwort ist leer Invalid: Passwort ungültig InvalidAndLocked: Password ist ungültig und Benutzer wurde gesperrt, melden Sie sich bei ihrem Administrator. + NotChanged: Passwort nicht geändert UsernameOrPassword: Invalid: Username oder Passwort ist ungültig PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/en.yaml b/internal/api/ui/login/static/i18n/en.yaml index ceb60654e8..3e06b634fb 100644 --- a/internal/api/ui/login/static/i18n/en.yaml +++ b/internal/api/ui/login/static/i18n/en.yaml @@ -399,6 +399,7 @@ Errors: Empty: Password is empty Invalid: Password is invalid InvalidAndLocked: Password is invalid and user is locked, contact your administrator. + NotChanged: Password not changed UsernameOrPassword: Invalid: Username or Password is invalid PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/es.yaml b/internal/api/ui/login/static/i18n/es.yaml index 7adf48d537..241ea2d930 100644 --- a/internal/api/ui/login/static/i18n/es.yaml +++ b/internal/api/ui/login/static/i18n/es.yaml @@ -381,6 +381,7 @@ Errors: Empty: La contraseña está vacía Invalid: La contraseña no es válida InvalidAndLocked: La contraseña no es válida y el usuario está bloqueado, contacta con tu administrador. + NotChanged: Contraseña no modificada UsernameOrPassword: Invalid: El nombre de usuario o la contraseña no son válidos PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/fr.yaml b/internal/api/ui/login/static/i18n/fr.yaml index 7cd2b0ad8c..45e62770d3 100644 --- a/internal/api/ui/login/static/i18n/fr.yaml +++ b/internal/api/ui/login/static/i18n/fr.yaml @@ -399,6 +399,7 @@ Errors: Empty: Le mot de passe est vide Invalid: Le mot de passe n'est pas valide InvalidAndLocked: Le mot de passe n'est pas valide et l'utilisateur est verrouillé, contactez votre administrateur. + NotChanged: Mot de passe non modifié UsernameOrPassword: Invalid: Le nom d'utilisateur ou le mot de passe n'est pas valide PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/it.yaml b/internal/api/ui/login/static/i18n/it.yaml index 8a30e9f976..3aa6c5c54b 100644 --- a/internal/api/ui/login/static/i18n/it.yaml +++ b/internal/api/ui/login/static/i18n/it.yaml @@ -399,6 +399,7 @@ Errors: Empty: La password è vuota Invalid: La password non è valida InvalidAndLocked: La password non è valida e l'utente è bloccato, contatta il tuo amministratore. + NotChanged: Password non modificata UsernameOrPassword: Invalid: Il nome utente o la password non sono validi PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/ja.yaml b/internal/api/ui/login/static/i18n/ja.yaml index 599710131c..9db77893c8 100644 --- a/internal/api/ui/login/static/i18n/ja.yaml +++ b/internal/api/ui/login/static/i18n/ja.yaml @@ -362,6 +362,7 @@ Errors: Empty: パスワードが空です Invalid: 無効なパスワードです InvalidAndLocked: パスワードが無効かつユーザーがロックされているため、管理者に連絡してください。 + NotChanged: パスワードは変更されていません UsernameOrPassword: Invalid: ユーザー名またはパスワードは無効です PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/mk.yaml b/internal/api/ui/login/static/i18n/mk.yaml index d17f2fdbbf..9f6dc6fc51 100644 --- a/internal/api/ui/login/static/i18n/mk.yaml +++ b/internal/api/ui/login/static/i18n/mk.yaml @@ -401,6 +401,7 @@ Errors: Empty: Лозинката е празна Invalid: Лозинката не е валидна InvalidAndLocked: Лозинката не е валидна и корисникот е заклучен, контактирајте со вашиот администратор. + NotChanged: Лозинката не е променета UsernameOrPassword: Invalid: Корисничкото име и/или лозинката не се валидни PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/pl.yaml b/internal/api/ui/login/static/i18n/pl.yaml index 56d4cc6838..e4046b95f7 100644 --- a/internal/api/ui/login/static/i18n/pl.yaml +++ b/internal/api/ui/login/static/i18n/pl.yaml @@ -399,6 +399,7 @@ Errors: Empty: Hasło jest puste Invalid: Hasło jest niepoprawne InvalidAndLocked: Hasło jest niepoprawne i użytkownik jest zablokowany, skontaktuj się z administratorem. + NotChanged: Hasło nie zostało zmienione UsernameOrPassword: Invalid: Nazwa użytkownika lub hasło jest niepoprawne PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/pt.yaml b/internal/api/ui/login/static/i18n/pt.yaml index e887ff6bca..cba0948f72 100644 --- a/internal/api/ui/login/static/i18n/pt.yaml +++ b/internal/api/ui/login/static/i18n/pt.yaml @@ -397,6 +397,7 @@ Errors: Empty: A senha está vazia Invalid: A senha é inválida InvalidAndLocked: A senha é inválida e o usuário está bloqueado, entre em contato com o administrador. + NotChanged: Senha não alterada UsernameOrPassword: Invalid: Nome de usuário ou senha inválidos PasswordComplexityPolicy: diff --git a/internal/api/ui/login/static/i18n/zh.yaml b/internal/api/ui/login/static/i18n/zh.yaml index 0680fa267e..eb27f0de2a 100644 --- a/internal/api/ui/login/static/i18n/zh.yaml +++ b/internal/api/ui/login/static/i18n/zh.yaml @@ -399,6 +399,7 @@ Errors: Empty: 密码为空 Invalid: 密码无效 InvalidAndLocked: 密码无效且用户被锁定,请联系您的管理员。 + NotChanged: 密码未更改 UsernameOrPassword: Invalid: 用户名或密码无效 PasswordComplexityPolicy: diff --git a/internal/command/user_human_password_model.go b/internal/command/user_human_password_model.go index c0ca58f58a..c4064ba157 100644 --- a/internal/command/user_human_password_model.go +++ b/internal/command/user_human_password_model.go @@ -90,6 +90,7 @@ func (wm *HumanPasswordWriteModel) Query() *eventstore.SearchQueryBuilder { user.HumanEmailVerifiedType, user.HumanPasswordCheckFailedType, user.HumanPasswordCheckSucceededType, + user.HumanPasswordHashUpdatedType, user.UserRemovedType, user.UserUnlockedType, user.UserV1AddedType, @@ -101,7 +102,7 @@ func (wm *HumanPasswordWriteModel) Query() *eventstore.SearchQueryBuilder { user.UserV1EmailVerifiedType, user.UserV1PasswordCheckFailedType, user.UserV1PasswordCheckSucceededType, - user.UserV1PasswordHashUpdatedType). + ). Builder() if wm.ResourceOwner != "" { diff --git a/internal/query/user_password.go b/internal/query/user_password.go index 97ca99541d..9d8ab71405 100644 --- a/internal/query/user_password.go +++ b/internal/query/user_password.go @@ -126,6 +126,7 @@ func (wm *HumanPasswordReadModel) Query() *eventstore.SearchQueryBuilder { user.HumanEmailVerifiedType, user.HumanPasswordCheckFailedType, user.HumanPasswordCheckSucceededType, + user.HumanPasswordHashUpdatedType, user.UserRemovedType, user.UserUnlockedType, user.UserV1AddedType, @@ -137,7 +138,7 @@ func (wm *HumanPasswordReadModel) Query() *eventstore.SearchQueryBuilder { user.UserV1EmailVerifiedType, user.UserV1PasswordCheckFailedType, user.UserV1PasswordCheckSucceededType, - user.UserV1PasswordHashUpdatedType). + ). Builder() if wm.ResourceOwner != "" { diff --git a/internal/repository/user/eventstore.go b/internal/repository/user/eventstore.go index 847736b60b..1505c31cff 100644 --- a/internal/repository/user/eventstore.go +++ b/internal/repository/user/eventstore.go @@ -17,7 +17,6 @@ func RegisterEventMappers(es *eventstore.Eventstore) { RegisterFilterEventMapper(AggregateType, UserV1PasswordCodeSentType, HumanPasswordCodeSentEventMapper). RegisterFilterEventMapper(AggregateType, UserV1PasswordCheckSucceededType, HumanPasswordCheckSucceededEventMapper). RegisterFilterEventMapper(AggregateType, UserV1PasswordCheckFailedType, HumanPasswordCheckFailedEventMapper). - RegisterFilterEventMapper(AggregateType, UserV1PasswordHashUpdatedType, eventstore.GenericEventMapper[HumanPasswordHashUpdatedEvent]). RegisterFilterEventMapper(AggregateType, UserV1EmailChangedType, HumanEmailChangedEventMapper). RegisterFilterEventMapper(AggregateType, UserV1EmailVerifiedType, HumanEmailVerifiedEventMapper). RegisterFilterEventMapper(AggregateType, UserV1EmailVerificationFailedType, HumanEmailVerificationFailedEventMapper). @@ -63,6 +62,7 @@ func RegisterEventMappers(es *eventstore.Eventstore) { RegisterFilterEventMapper(AggregateType, HumanPasswordChangeSentType, HumanPasswordChangeSentEventMapper). RegisterFilterEventMapper(AggregateType, HumanPasswordCheckSucceededType, HumanPasswordCheckSucceededEventMapper). RegisterFilterEventMapper(AggregateType, HumanPasswordCheckFailedType, HumanPasswordCheckFailedEventMapper). + RegisterFilterEventMapper(AggregateType, HumanPasswordHashUpdatedType, eventstore.GenericEventMapper[HumanPasswordHashUpdatedEvent]). RegisterFilterEventMapper(AggregateType, UserIDPLinkAddedType, UserIDPLinkAddedEventMapper). RegisterFilterEventMapper(AggregateType, UserIDPLinkRemovedType, UserIDPLinkRemovedEventMapper). RegisterFilterEventMapper(AggregateType, UserIDPLinkCascadeRemovedType, UserIDPLinkCascadeRemovedEventMapper). diff --git a/internal/repository/user/human_password.go b/internal/repository/user/human_password.go index f2f40cd6ce..909da24261 100644 --- a/internal/repository/user/human_password.go +++ b/internal/repository/user/human_password.go @@ -21,6 +21,7 @@ const ( HumanPasswordCodeSentType = passwordEventPrefix + "code.sent" HumanPasswordCheckSucceededType = passwordEventPrefix + "check.succeeded" HumanPasswordCheckFailedType = passwordEventPrefix + "check.failed" + HumanPasswordHashUpdatedType = passwordEventPrefix + "hash.updated" ) type HumanPasswordChangedEvent struct { @@ -298,7 +299,7 @@ func NewHumanPasswordHashUpdatedEvent( BaseEvent: *eventstore.NewBaseEventForPush( ctx, aggregate, - HumanPasswordCheckFailedType, + HumanPasswordHashUpdatedType, ), EncodedHash: encoded, } diff --git a/internal/repository/user/v1.go b/internal/repository/user/v1.go index a2974bad98..010e1a235d 100644 --- a/internal/repository/user/v1.go +++ b/internal/repository/user/v1.go @@ -15,7 +15,6 @@ const ( UserV1PasswordCodeSentType = userV1PasswordEventTypePrefix + "code.sent" UserV1PasswordCheckSucceededType = userV1PasswordEventTypePrefix + "check.succeeded" UserV1PasswordCheckFailedType = userV1PasswordEventTypePrefix + "check.failed" - UserV1PasswordHashUpdatedType = userV1PasswordEventTypePrefix + "hash.updated" userV1EmailEventTypePrefix = userEventTypePrefix + "email." UserV1EmailChangedType = userV1EmailEventTypePrefix + "changed" diff --git a/internal/static/i18n/bg.yaml b/internal/static/i18n/bg.yaml index 959c5fbbff..33dd828a72 100644 --- a/internal/static/i18n/bg.yaml +++ b/internal/static/i18n/bg.yaml @@ -682,6 +682,10 @@ EventTypes: check: succeeded: Проверката на паролата е успешна failed: Проверката на паролата е неуспешна + change: + sent: Промяната на паролата е изпратена + hash: + updated: Хешът на паролата е актуализиран phone: changed: Телефонният номер е променен verified: Телефонният номер е потвърден diff --git a/internal/static/i18n/de.yaml b/internal/static/i18n/de.yaml index 929ce1db6d..b485f65c67 100644 --- a/internal/static/i18n/de.yaml +++ b/internal/static/i18n/de.yaml @@ -583,6 +583,10 @@ EventTypes: check: succeeded: Passwortvalidierung erfolgreich failed: Passwortvalidierung fehlgeschlagen + change: + sent: Passwordänderung versendet + hash: + updated: Passwort Hash geändert externallogin: check: succeeded: Externer login erfolgreich durchgeführt diff --git a/internal/static/i18n/en.yaml b/internal/static/i18n/en.yaml index f623dc2133..93a5290456 100644 --- a/internal/static/i18n/en.yaml +++ b/internal/static/i18n/en.yaml @@ -583,6 +583,10 @@ EventTypes: check: succeeded: Password check succeeded failed: Password check failed + change: + sent: Password change sent + hash: + updated: Password hash updated externallogin: check: succeeded: External login succeeded diff --git a/internal/static/i18n/es.yaml b/internal/static/i18n/es.yaml index 097bd9e7c1..5dc4a3ab49 100644 --- a/internal/static/i18n/es.yaml +++ b/internal/static/i18n/es.yaml @@ -583,6 +583,10 @@ EventTypes: check: succeeded: Comprobación exitosa de la contraseña failed: Fallo en la comprobación de la contraseña + change: + sent: Cambio de contraseña enviado + hash: + updated: Hash de contraseña actualizado externallogin: check: succeeded: Inicio de sesión externo con éxito diff --git a/internal/static/i18n/fr.yaml b/internal/static/i18n/fr.yaml index 7fba4deaf2..b80a9ed33e 100644 --- a/internal/static/i18n/fr.yaml +++ b/internal/static/i18n/fr.yaml @@ -581,6 +581,10 @@ EventTypes: check: succeeded: Vérification du mot de passe réussie failed: La vérification du mot de passe a échoué + change: + sent: Changement de mot de passe envoyé + hash: + updated: Hachage du mot de passe mis à jour externallogin: check: succeeded: Connexion externe réussie diff --git a/internal/static/i18n/it.yaml b/internal/static/i18n/it.yaml index 4981dc3070..e1bd873bb1 100644 --- a/internal/static/i18n/it.yaml +++ b/internal/static/i18n/it.yaml @@ -581,6 +581,10 @@ EventTypes: check: succeeded: Controllo della password riuscito failed: Controllo della password fallito + change: + sent: Cambio password inviato + hash: + updated: Hash della password aggiornato externallogin: check: succeeded: Accesso esterno riuscito diff --git a/internal/static/i18n/ja.yaml b/internal/static/i18n/ja.yaml index d0ba74e274..eadf7ad5ab 100644 --- a/internal/static/i18n/ja.yaml +++ b/internal/static/i18n/ja.yaml @@ -655,6 +655,10 @@ EventTypes: check: succeeded: パスワードチェックの成功 failed: パスワードチェックの失敗 + change: + sent: パスワード変更を送信しました + hash: + updated: パスワードハッシュが更新されました phone: changed: 電話番号の変更 verified: 電話番号の検証 diff --git a/internal/static/i18n/mk.yaml b/internal/static/i18n/mk.yaml index a02b79dc91..c3fcfdf69b 100644 --- a/internal/static/i18n/mk.yaml +++ b/internal/static/i18n/mk.yaml @@ -666,6 +666,10 @@ EventTypes: check: succeeded: Проверката на лозинката е успешна failed: Проверката на лозинката е неуспешна + change: + sent: Промената на лозинката е испратена + hash: + updated: Хашот на лозинката е ажуриран phone: changed: Бројот на телефонот е променет verified: Бројот на телефонот е верифициран diff --git a/internal/static/i18n/pl.yaml b/internal/static/i18n/pl.yaml index 3e48f45825..aa84c8ca5b 100644 --- a/internal/static/i18n/pl.yaml +++ b/internal/static/i18n/pl.yaml @@ -583,6 +583,10 @@ EventTypes: check: succeeded: Sprawdzenie hasła zakończone powodzeniem failed: Sprawdzenie hasła nie powiodło się + change: + sent: Wysłano zmianę hasła + hash: + updated: Zaktualizowano skrót hasła externallogin: check: succeeded: Zewnętrzne logowanie zakończone powodzeniem diff --git a/internal/static/i18n/pt.yaml b/internal/static/i18n/pt.yaml index 963191eb55..4f3c5af85c 100644 --- a/internal/static/i18n/pt.yaml +++ b/internal/static/i18n/pt.yaml @@ -120,6 +120,7 @@ Errors: Empty: Senha está vazia Invalid: Senha é inválida NotSet: O usuário não definiu uma senha + NotChanged: Senha não alterada PasswordComplexityPolicy: NotFound: Política de complexidade de senha não encontrada MinLength: A senha é muito curta @@ -660,6 +661,10 @@ EventTypes: check: succeeded: Verificação de senha bem-sucedida failed: Verificação de senha falhou + change: + sent: Alteração de senha enviada + hash: + updated: Hash da senha atualizado phone: changed: Número de telefone alterado verified: Número de telefone verificado diff --git a/internal/static/i18n/zh.yaml b/internal/static/i18n/zh.yaml index 1209fd5159..fb068a2337 100644 --- a/internal/static/i18n/zh.yaml +++ b/internal/static/i18n/zh.yaml @@ -664,6 +664,10 @@ EventTypes: check: succeeded: 密码检查成功 failed: 密码检查失败 + change: + sent: 密码更改已发送 + hash: + updated: 密码哈希已更新 phone: changed: 更改手机号码 verified: 验证手机号码