From 629ca22a975d74cf6d02bbb25963195d4d21ff5b Mon Sep 17 00:00:00 2001 From: Anbraten <6918444+anbraten@users.noreply.github.com> Date: Fri, 5 Jul 2024 19:10:09 +0200 Subject: [PATCH 1/6] Refactor login page (#31530) As requested in https://github.com/go-gitea/gitea/pull/31504#issuecomment-2196196646. This PR refactor the login page: ![Screenshot from 2024-07-04 19-23-10](https://github.com/go-gitea/gitea/assets/6918444/c45700f4-6747-473c-bdee-2156718a7953) ![Screenshot from 2024-07-04 19-23-21](https://github.com/go-gitea/gitea/assets/6918444/b1bf71cf-85f9-4517-a409-cc6d72e6af8f) ![Screenshot from 2024-06-30 09-35-20](https://github.com/go-gitea/gitea/assets/6918444/728cc37e-0cca-4883-afec-a43663d2c666) - [x] use separate box for passkey login and go to registration - [x] move forgot passoword next to password label - [x] fix password required label `*` and padding - [x] remove tabs from login page --------- Co-authored-by: silverwind (cherry picked from commit 9c00dda33ad7bd594dd8f331fa1bf0acefc2ca54) Conflict resolution: * signin_navbar.tmpl has been deleted * additions in form.css * major code changes in signin_openid * ... --- options/locale/locale_en-US.ini | 8 +- templates/user/auth/captcha.tmpl | 9 +- templates/user/auth/oauth_container.tmpl | 29 ++++++ templates/user/auth/signin.tmpl | 3 +- templates/user/auth/signin_inner.tmpl | 127 +++++++++++------------ templates/user/auth/signin_navbar.tmpl | 24 ----- templates/user/auth/signin_openid.tmpl | 69 +++++++----- templates/user/auth/signup.tmpl | 5 +- templates/user/auth/signup_inner.tmpl | 41 +++----- web_src/css/form.css | 18 ++++ 10 files changed, 178 insertions(+), 155 deletions(-) create mode 100644 templates/user/auth/oauth_container.tmpl delete mode 100644 templates/user/auth/signin_navbar.tmpl diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index bac0e8515..b5bd43599 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -399,8 +399,8 @@ relevant_repositories = Only relevant repositories are being shown, %s. Please check your inbox within the next %s to complete the registration process. If the email is incorrect, you can log in, and request another confirmation email to be sent to a different address. must_change_password = Update your password @@ -473,6 +474,7 @@ sspi_auth_failed = SSPI authentication failed password_pwned = The password you chose is on a list of stolen passwords previously exposed in public data breaches. Please try again with a different password and consider changing this password elsewhere too. password_pwned_err = Could not complete request to HaveIBeenPwned last_admin = You cannot remove the last admin. There must be at least one admin. +back_to_sign_in = Back to Sign In [mail] view_it_on = View it on %s diff --git a/templates/user/auth/captcha.tmpl b/templates/user/auth/captcha.tmpl index 0e9c2b9d2..8dd4d1cc5 100644 --- a/templates/user/auth/captcha.tmpl +++ b/templates/user/auth/captcha.tmpl @@ -1,5 +1,5 @@ {{if .EnableCaptcha}}{{if eq .CaptchaType "image"}} -
+
{{.Captcha.CreateHTML}}
@@ -7,18 +7,17 @@
{{else if eq .CaptchaType "recaptcha"}} -
+
{{else if eq .CaptchaType "hcaptcha"}} -
+
{{else if eq .CaptchaType "mcaptcha"}} -
- +
diff --git a/templates/user/auth/oauth_container.tmpl b/templates/user/auth/oauth_container.tmpl new file mode 100644 index 000000000..7599b49fb --- /dev/null +++ b/templates/user/auth/oauth_container.tmpl @@ -0,0 +1,29 @@ +{{if or .OAuth2Providers .EnableOpenIDSignIn}} +
+ {{ctx.Locale.Tr "sign_in_or"}} +
+ +{{end}} diff --git a/templates/user/auth/signin.tmpl b/templates/user/auth/signin.tmpl index b0e9ce8c7..54cc82d49 100644 --- a/templates/user/auth/signin.tmpl +++ b/templates/user/auth/signin.tmpl @@ -1,8 +1,7 @@ {{template "base/head" .}}
- {{template "user/auth/signin_navbar" .}}
-
+
{{template "user/auth/signin_inner" .}}
diff --git a/templates/user/auth/signin_inner.tmpl b/templates/user/auth/signin_inner.tmpl index 9872096fb..b0a52d2c6 100644 --- a/templates/user/auth/signin_inner.tmpl +++ b/templates/user/auth/signin_inner.tmpl @@ -1,70 +1,65 @@ -{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn)}} -{{template "base/alert" .}} -{{end}} -

- {{if .LinkAccountMode}} - {{ctx.Locale.Tr "auth.oauth_signin_title"}} - {{else}} - {{ctx.Locale.Tr "auth.login_userpass"}} +
+ {{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn)}} + {{template "base/alert" .}} {{end}} -

-
-
- {{.CsrfTokenHtml}} -
- - -
- {{if or (not .DisablePassword) .LinkAccountMode}} -
- - -
- {{end}} - {{if not .LinkAccountMode}} -
-
- - -
-
- {{end}} - - {{template "user/auth/captcha" .}} - -
- - {{ctx.Locale.Tr "auth.forgot_password"}} -
- - {{if .ShowRegistrationButton}} - - {{end}} - - {{if .OAuth2Providers}} -
- {{ctx.Locale.Tr "sign_in_or"}} -
-
-
-
- {{range $provider := .OAuth2Providers}} - - {{end}} +

+ {{if .LinkAccountMode}} + {{ctx.Locale.Tr "auth.oauth_signin_title"}} + {{else}} + {{ctx.Locale.Tr "auth.login_userpass"}} + {{end}} +

+
+ + {{.CsrfTokenHtml}} +
+ +
-
+ {{if or (not .DisablePassword) .LinkAccountMode}} +
+ + {{ctx.Locale.Tr "auth.forgot_password"}} + +
+ {{end}} + {{if not .LinkAccountMode}} +
+
+ + +
+
+ {{end}} + + {{template "user/auth/captcha" .}} + +
+ +
+ + + {{template "user/auth/oauth_container" .}} +
+
+ +
+ {{template "user/auth/webauthn_error" .}} + +
+ + + {{if .ShowRegistrationButton}} +
+ {{ctx.Locale.Tr "auth.need_account"}} + {{ctx.Locale.Tr "auth.sign_up_now"}} +
+ {{end}}
- {{end}} -
diff --git a/templates/user/auth/signin_navbar.tmpl b/templates/user/auth/signin_navbar.tmpl deleted file mode 100644 index 01b994b98..000000000 --- a/templates/user/auth/signin_navbar.tmpl +++ /dev/null @@ -1,24 +0,0 @@ -{{if or .EnableOpenIDSignIn .EnableSSPI}} - - - -{{end}} diff --git a/templates/user/auth/signin_openid.tmpl b/templates/user/auth/signin_openid.tmpl index c1f392dc1..20c7bdc92 100644 --- a/templates/user/auth/signin_openid.tmpl +++ b/templates/user/auth/signin_openid.tmpl @@ -1,35 +1,50 @@ {{template "base/head" .}}