Skip to content

Commit

Permalink
Bug 1958080: Add missing error page strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jhadvig committed May 10, 2021
1 parent 3da20bd commit 5d6a68b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions pkg/server/locales/locales.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ var supportedLangs = []language.Tag{
}

var locale_en = Localization{
"LogInToYourAccount": "Log in to your account",
"Username": "Username",
"Password": "Password",
"LogIn": "Log in",
"WelcomeTo": "Welcome to",
"LogInWith": "Log in with",
"Error": "Error",
"LogInToYourAccount": "Log in to your account",
"Username": "Username",
"Password": "Password",
"LogIn": "Log in",
"WelcomeTo": "Welcome to",
"LogInWith": "Log in with",
"Error": "Error",
"LoginIsRequiredPleaseTryAgain": "Login is required. Please try again.",
"CouldNotCheckCSRFTokenPleaseTryAgain": "Could not check CSRF token. Please try again.",
"InvalidLoginOrPasswordPleaseTryAgain": "Invalid login or password. Please try again.",
}

var locale_zh = Localization{
Expand Down
8 changes: 4 additions & 4 deletions pkg/server/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const (
// Error messages that correlate to the error codes above.
// General authentication error messages are found in the error page package
var errorMessages = map[string]string{
errorCodeUserRequired: "Login is required. Please try again.",
errorCodeTokenExpired: "Could not check CSRF token. Please try again.",
errorCodeAccessDenied: "Invalid login or password. Please try again.",
errorCodeUserRequired: "LoginIsRequiredPleaseTryAgain",
errorCodeTokenExpired: "CouldNotCheckCSRFTokenPleaseTryAgain",
errorCodeAccessDenied: "InvalidLoginOrPasswordPleaseTryAgain",
}

type PasswordAuthenticator interface {
Expand Down Expand Up @@ -134,7 +134,7 @@ func (l *Login) handleLoginForm(w http.ResponseWriter, req *http.Request) {
form.Locale = locales.GetLocale(req.Header.Get("Accept-Language"))
form.ErrorCode = req.URL.Query().Get(reasonParam)
if len(form.ErrorCode) > 0 {
if msg, hasMsg := errorMessages[form.ErrorCode]; hasMsg {
if msg, hasMsg := form.Locale[errorMessages[form.ErrorCode]]; hasMsg {
form.Error = msg
} else {
form.Error = errorpage.AuthenticationErrorMessage(form.ErrorCode)
Expand Down

0 comments on commit 5d6a68b

Please sign in to comment.