Skip to content

Commit 9c00dda

Browse files
anbratensilverwind
andauthored
Refactor login page (#31530)
As requested in #31504 (comment). 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) # Changes - [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 <[email protected]>
1 parent b88e5fc commit 9c00dda

10 files changed

+166
-153
lines changed

options/locale/locale_en-US.ini

+5-3
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,17 @@ relevant_repositories = Only relevant repositories are being shown, <a href="%s"
387387

388388
[auth]
389389
create_new_account = Register Account
390-
register_helper_msg = Already have an account? Sign in now!
391-
social_register_helper_msg = Already have an account? Link it now!
390+
already_have_account = Already have an account?
391+
sign_in_now = Sign in now!
392392
disable_register_prompt = Registration is disabled. Please contact your site administrator.
393393
disable_register_mail = Email confirmation for registration is disabled.
394394
manual_activation_only = Contact your site administrator to complete activation.
395395
remember_me = Remember This Device
396396
remember_me.compromised = The login token is not valid anymore which may indicate a compromised account. Please check your account for unusual activities.
397397
forgot_password_title= Forgot Password
398398
forgot_password = Forgot password?
399-
sign_up_now = Need an account? Register now.
399+
need_account = Need an account?
400+
sign_up_now = Register now.
400401
sign_up_successful = Account was successfully created. Welcome!
401402
confirmation_mail_sent_prompt_ex = A new confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %s to complete the registration process. If your registration email address is incorrect, you can sign in again and change it.
402403
must_change_password = Update your password
@@ -459,6 +460,7 @@ password_pwned = The password you chose is on a <a target="_blank" rel="noopener
459460
password_pwned_err = Could not complete request to HaveIBeenPwned
460461
last_admin = You cannot remove the last admin. There must be at least one admin.
461462
signin_passkey = Sign in with a passkey
463+
back_to_sign_in = Back to Sign In
462464
463465
[mail]
464466
view_it_on = View it on %s

templates/user/auth/captcha.tmpl

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
{{if .EnableCaptcha}}{{if eq .CaptchaType "image"}}
2-
<div class="inline field">
2+
<div class="inline field tw-text-center">
33
{{.Captcha.CreateHTML}}
44
</div>
55
<div class="required field {{if .Err_Captcha}}error{{end}}">
66
<label for="captcha">{{ctx.Locale.Tr "captcha"}}</label>
77
<input id="captcha" name="captcha" value="{{.captcha}}" autocomplete="off">
88
</div>
99
{{else if eq .CaptchaType "recaptcha"}}
10-
<div class="inline field required">
10+
<div class="inline field tw-text-center required">
1111
<div id="captcha" data-captcha-type="g-recaptcha" class="g-recaptcha-style" data-sitekey="{{.RecaptchaSitekey}}"></div>
1212
</div>
1313
<script src='{{URLJoin .RecaptchaURL "api.js"}}'></script>
1414
{{else if eq .CaptchaType "hcaptcha"}}
15-
<div class="inline field required">
15+
<div class="inline field tw-text-center required">
1616
<div id="captcha" data-captcha-type="h-captcha" class="h-captcha-style" data-sitekey="{{.HcaptchaSitekey}}"></div>
1717
</div>
1818
<script src='https://hcaptcha.com/1/api.js'></script>
1919
{{else if eq .CaptchaType "mcaptcha"}}
20-
<div class="inline field">
21-
<label></label>
20+
<div class="inline field tw-text-center">
2221
<div class="m-captcha-style" id="mcaptcha__widget-container"></div>
2322
<div id="captcha" data-captcha-type="m-captcha" data-sitekey="{{.McaptchaSitekey}}" data-instance-url="{{.McaptchaURL}}"></div>
2423
</div>
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{if or .OAuth2Providers .EnableOpenIDSignIn}}
2+
<div class="divider divider-text">
3+
{{ctx.Locale.Tr "sign_in_or"}}
4+
</div>
5+
<div id="oauth2-login-navigator" class="tw-py-1">
6+
<div class="tw-flex tw-flex-col tw-justify-center">
7+
<div id="oauth2-login-navigator-inner" class="tw-flex tw-flex-col tw-flex-wrap tw-items-center tw-gap-2">
8+
{{range $provider := .OAuth2Providers}}
9+
<a class="{{$provider.Name}} ui button tw-flex tw-items-center tw-justify-center tw-py-2 tw-w-full oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$provider.DisplayName}}">
10+
{{$provider.IconHTML 28}}
11+
{{ctx.Locale.Tr "sign_in_with_provider" $provider.DisplayName}}
12+
</a>
13+
{{end}}
14+
{{if .EnableOpenIDSignIn}}
15+
<a class="openid ui button tw-flex tw-items-center tw-justify-center tw-py-2 tw-w-full" href="{{AppSubUrl}}/user/login/openid">
16+
{{svg "fontawesome-openid" 28 "tw-mr-2"}}
17+
{{ctx.Locale.Tr "sign_in_with_provider" "OpenID"}}
18+
</a>
19+
{{end}}
20+
{{if .EnableSSPI}}
21+
<a class="ui button tw-flex tw-items-center tw-justify-center tw-py-2 tw-w-full" rel="nofollow" href="{{AppSubUrl}}/user/login?auth_with_sspi=1">
22+
{{svg "fontawesome-windows"}}
23+
&nbsp;SSPI
24+
</a>
25+
{{end}}
26+
</div>
27+
</div>
28+
</div>
29+
{{end}}

templates/user/auth/signin.tmpl

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content user signin{{if .LinkAccountMode}} icon{{end}}">
3-
{{template "user/auth/signin_navbar" .}}
43
<div class="ui middle very relaxed page grid">
5-
<div class="ui container column fluid">
4+
<div class="column tw-flex tw-flex-col tw-gap-4 tw-max-w-2xl tw-m-auto">
65
{{template "user/auth/signin_inner" .}}
76
</div>
87
</div>

templates/user/auth/signin_inner.tmpl

+53-64
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,65 @@
1-
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn)}}
2-
{{template "base/alert" .}}
3-
{{end}}
4-
<h4 class="ui top attached header center">
5-
{{if .LinkAccountMode}}
6-
{{ctx.Locale.Tr "auth.oauth_signin_title"}}
7-
{{else}}
8-
{{ctx.Locale.Tr "auth.login_userpass"}}
1+
<div class="ui container fluid">
2+
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn)}}
3+
{{template "base/alert" .}}
94
{{end}}
10-
</h4>
11-
<div class="ui attached segment">
12-
{{template "user/auth/webauthn_error" .}}
5+
<h4 class="ui top attached header center">
6+
{{if .LinkAccountMode}}
7+
{{ctx.Locale.Tr "auth.oauth_signin_title"}}
8+
{{else}}
9+
{{ctx.Locale.Tr "auth.login_userpass"}}
10+
{{end}}
11+
</h4>
12+
<div class="ui attached segment">
13+
<form class="ui form" action="{{.SignInLink}}" method="post">
14+
{{.CsrfTokenHtml}}
15+
<div class="required field {{if and (.Err_UserName) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn))}}error{{end}}">
16+
<label for="user_name">{{ctx.Locale.Tr "home.uname_holder"}}</label>
17+
<input id="user_name" type="text" name="user_name" value="{{.user_name}}" autofocus required>
18+
</div>
19+
{{if or (not .DisablePassword) .LinkAccountMode}}
20+
<div class="required field {{if and (.Err_Password) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn))}}error{{end}} form-field-content-aside-label">
21+
<label for="password">{{ctx.Locale.Tr "password"}}</label>
22+
<a href="{{AppSubUrl}}/user/forgot_password">{{ctx.Locale.Tr "auth.forgot_password"}}</a>
23+
<input id="password" name="password" type="password" value="{{.password}}" autocomplete="current-password" required>
24+
</div>
25+
{{end}}
26+
{{if not .LinkAccountMode}}
27+
<div class="inline field">
28+
<div class="ui checkbox">
29+
<label>{{ctx.Locale.Tr "auth.remember_me"}}</label>
30+
<input name="remember" type="checkbox">
31+
</div>
32+
</div>
33+
{{end}}
1334

14-
<form class="ui form tw-max-w-2xl tw-m-auto" action="{{.SignInLink}}" method="post">
15-
{{.CsrfTokenHtml}}
16-
<div class="required field {{if and (.Err_UserName) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn))}}error{{end}}">
17-
<label for="user_name">{{ctx.Locale.Tr "home.uname_holder"}}</label>
18-
<input id="user_name" type="text" name="user_name" value="{{.user_name}}" autofocus required>
19-
</div>
20-
{{if or (not .DisablePassword) .LinkAccountMode}}
21-
<div class="required field {{if and (.Err_Password) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn))}}error{{end}}">
22-
<label for="password">{{ctx.Locale.Tr "password"}}</label>
23-
<input id="password" name="password" type="password" value="{{.password}}" autocomplete="current-password" required>
24-
</div>
25-
{{end}}
26-
{{if not .LinkAccountMode}}
27-
<div class="inline field">
28-
<div class="ui checkbox">
29-
<label>{{ctx.Locale.Tr "auth.remember_me"}}</label>
30-
<input name="remember" type="checkbox">
31-
</div>
32-
</div>
33-
{{end}}
35+
{{template "user/auth/captcha" .}}
3436

35-
{{template "user/auth/captcha" .}}
37+
<div class="field">
38+
<button class="ui primary button tw-w-full">
39+
{{if .LinkAccountMode}}
40+
{{ctx.Locale.Tr "auth.oauth_signin_submit"}}
41+
{{else}}
42+
{{ctx.Locale.Tr "sign_in"}}
43+
{{end}}
44+
</button>
45+
</div>
46+
</form>
3647

37-
<div class="field">
38-
<button class="ui primary button">
39-
{{if .LinkAccountMode}}
40-
{{ctx.Locale.Tr "auth.oauth_signin_submit"}}
41-
{{else}}
42-
{{ctx.Locale.Tr "sign_in"}}
43-
{{end}}
44-
</button>
45-
<a href="{{AppSubUrl}}/user/forgot_password">{{ctx.Locale.Tr "auth.forgot_password"}}</a>
48+
{{template "user/auth/oauth_container" .}}
4649
</div>
50+
</div>
4751

48-
{{if .ShowRegistrationButton}}
49-
<div class="field">
50-
<a href="{{AppSubUrl}}/user/sign_up">{{ctx.Locale.Tr "auth.sign_up_now"}}</a>
51-
</div>
52-
{{end}}
52+
<div class="ui container fluid">
53+
{{template "user/auth/webauthn_error" .}}
5354

54-
<div class="field">
55+
<div class="ui attached segment header top tw-max-w-2xl tw-m-auto tw-flex tw-flex-col tw-items-center">
5556
<a class="signin-passkey">{{ctx.Locale.Tr "auth.signin_passkey"}}</a>
56-
</div>
5757

58-
{{if .OAuth2Providers}}
59-
<div class="divider divider-text">
60-
{{ctx.Locale.Tr "sign_in_or"}}
61-
</div>
62-
<div id="oauth2-login-navigator" class="tw-py-1">
63-
<div class="tw-flex tw-flex-col tw-justify-center">
64-
<div id="oauth2-login-navigator-inner" class="tw-flex tw-flex-col tw-flex-wrap tw-items-center tw-gap-2">
65-
{{range $provider := .OAuth2Providers}}
66-
<a class="{{$provider.Name}} ui button tw-flex tw-items-center tw-justify-center tw-py-2 tw-w-full oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$provider.DisplayName}}">
67-
{{$provider.IconHTML 28}}
68-
{{ctx.Locale.Tr "sign_in_with_provider" $provider.DisplayName}}
69-
</a>
70-
{{end}}
58+
{{if .ShowRegistrationButton}}
59+
<div class="field">
60+
<span>{{ctx.Locale.Tr "auth.need_account"}}</span>
61+
<a href="{{AppSubUrl}}/user/sign_up">{{ctx.Locale.Tr "auth.sign_up_now"}}</a>
7162
</div>
72-
</div>
63+
{{end}}
7364
</div>
74-
{{end}}
75-
</form>
7665
</div>

templates/user/auth/signin_navbar.tmpl

-24
This file was deleted.

templates/user/auth/signin_openid.tmpl

+42-27
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,50 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content user signin openid">
3-
{{template "user/auth/signin_navbar" .}}
4-
<div class="ui container">
5-
{{template "base/alert" .}}
6-
<h4 class="ui top attached header center">
7-
{{svg "fontawesome-openid"}}
8-
OpenID
9-
</h4>
10-
<div class="ui attached segment">
11-
<form class="ui form tw-m-auto" action="{{.Link}}" method="post">
12-
{{.CsrfTokenHtml}}
13-
<div class="inline field">
14-
{{ctx.Locale.Tr "auth.openid_signin_desc"}}
15-
</div>
16-
<div class="required field {{if .Err_OpenID}}error{{end}}">
17-
<label for="openid">
18-
{{svg "fontawesome-openid"}}
19-
OpenID URI
20-
</label>
21-
<input id="openid" name="openid" value="{{.openid}}" autofocus required>
22-
</div>
23-
<div class="inline field">
24-
<div class="ui checkbox">
25-
<label>{{ctx.Locale.Tr "auth.remember_me"}}</label>
26-
<input name="remember" type="checkbox">
3+
<div class="ui middle very relaxed page grid">
4+
<div class="column tw-flex tw-flex-col tw-gap-4 tw-max-w-2xl tw-m-auto">
5+
<a href="{{AppSubUrl}}/user/login" class="tw-mx-auto">
6+
<img width="100" height="100" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}">
7+
</a>
8+
9+
<div class="ui container fluid">
10+
{{template "base/alert" .}}
11+
<h4 class="ui top attached header center">
12+
{{svg "fontawesome-openid"}}
13+
OpenID
14+
</h4>
15+
<div class="ui attached segment">
16+
<form class="ui form tw-m-auto" action="{{.Link}}" method="post">
17+
{{.CsrfTokenHtml}}
18+
<div class="inline field">
19+
{{ctx.Locale.Tr "auth.openid_signin_desc"}}
20+
</div>
21+
<div class="required field {{if .Err_OpenID}}error{{end}}">
22+
<label for="openid">
23+
{{svg "fontawesome-openid"}}
24+
OpenID URI
25+
</label>
26+
<input id="openid" name="openid" value="{{.openid}}" autofocus required>
27+
</div>
28+
<div class="inline field">
29+
<div class="ui checkbox">
30+
<label>{{ctx.Locale.Tr "auth.remember_me"}}</label>
31+
<input name="remember" type="checkbox">
32+
</div>
33+
</div>
34+
<div class="inline field">
35+
<button class="ui primary button tw-w-full">{{ctx.Locale.Tr "sign_in"}}</button>
36+
</div>
37+
</form>
2738
</div>
2839
</div>
29-
<div class="inline field">
30-
<button class="ui primary button">{{ctx.Locale.Tr "sign_in"}}</button>
40+
41+
<div class="ui container fluid">
42+
{{template "user/auth/webauthn_error" .}}
43+
44+
<div class="ui attached segment header top tw-flex tw-flex-col tw-items-center">
45+
<a href="{{AppSubUrl}}/user/login">{{ctx.Locale.Tr "auth.back_to_sign_in"}}</a>
46+
</div>
3147
</div>
32-
</form>
3348
</div>
3449
</div>
3550
</div>

templates/user/auth/signup.tmpl

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content user signin{{if .LinkAccountMode}} icon{{end}}">
3-
{{template "user/auth/signin_navbar" .}}
43
<div class="ui middle very relaxed page grid">
5-
{{template "user/auth/signup_inner" .}}
4+
<div class="column tw-flex tw-flex-col tw-gap-4 tw-max-w-2xl tw-m-auto">
5+
{{template "user/auth/signup_inner" .}}
6+
</div>
67
</div>
78
</div>
89
{{template "base/footer" .}}

0 commit comments

Comments
 (0)