88 </ div >
99 </ div >
1010
11- <!-- Sign in -->
11+ <!-- Sign in / Register -->
1212 < div class ="flex flex-col lg:justify-center lg:w-1/3 mx-8 lg:mx-16 min-w-[50%] ">
1313 < div class ="mx-auto ">
1414 < div class ="my-12 xs:w-72 ">
15- < h2 class ="text-xl font-semibold lg:text-2xl "> Sign in</ h2 >
15+ < h2 class ="text-xl font-semibold lg:text-2xl ">
16+ {{ mode === 'login' ? 'Sign in' : 'Create account' }}
17+ </ h2 >
1618
1719 < div class ="text-gray-500 text-sm max-w-sm ">
1820 By signing in you accept our
@@ -24,41 +26,130 @@ <h2 class="text-xl font-semibold lg:text-2xl">Sign in</h2>
2426 @if ({ displayPassForm: false }; as ctx) {
2527 < div >
2628 @if (allowPassword && ctx.displayPassForm) {
27- < form class ="flex flex-col my-12 " [formGroup] ="form " (ngSubmit) ="submitForm() ">
28- < div class ="flex flex-col my-2 ">
29- < label class ="mb-1 text-sm " for ="username "> E-mail</ label >
30- < input
31- class ="input-outline mb-0 "
32- type ="email "
33- formControlName ="username "
34- placeholder ="email "
35- autocomplete ="email "
29+ <!-- Login Form -->
30+ @if (mode === 'login') {
31+ < form class ="flex flex-col my-12 " [formGroup] ="loginForm " (ngSubmit) ="submitLogin() ">
32+ < div class ="flex flex-col my-2 ">
33+ < label class ="mb-1 text-sm " for ="email "> E-mail</ label >
34+ < input
35+ class ="input-outline mb-0 "
36+ type ="email "
37+ formControlName ="email "
38+ placeholder ="you@example.com "
39+ autocomplete ="email "
3640 />
37- < span class ="text-xs pb-2 text-red ">
38- < form-error [control] ="form.get('username') "> </ form-error >
39- </ span >
40- </ div >
41- < div class ="flex flex-col my-2 ">
42- < label class ="mb-1 text-sm " for ="username "> Password</ label >
43- < input
44- class ="input-outline mb-0 "
45- type ="password "
46- formControlName ="password "
47- placeholder ="password "
48- autocomplete ="current-password "
41+ < span class ="text-xs pb-2 text-red ">
42+ < form-error [control] ="loginForm.get('email') "> </ form-error >
43+ </ span >
44+ </ div >
45+
46+ < div class ="flex flex-col my-2 ">
47+ < label class ="mb-1 text-sm " for ="password "> Password</ label >
48+ < input
49+ class ="input-outline mb-0 "
50+ type ="password "
51+ formControlName ="password "
52+ placeholder ="•••••••• "
53+ autocomplete ="current-password "
4954 />
50- < span class ="text-xs pb-2 text-red ">
51- < form-error [control] ="form.get('password') "> </ form-error >
52- </ span >
55+ < span class ="text-xs pb-2 text-red ">
56+ < form-error [control] ="loginForm.get('password') "> </ form-error >
57+ </ span >
58+ </ div >
59+
60+ < button
61+ class ="btn-blue shadow w-64 mt-2 "
62+ [disabled] ="loginForm.touched && loginForm.invalid || (loading$ | async) "
63+ type ="submit "
64+ >
65+ @if (loading$ | async) {
66+ < span > Signing in...</ span >
67+ } @else {
68+ Sign in
69+ }
70+ </ button >
71+
72+ @if (error$ | async; as error) {
73+ < p class ="text-red text-sm mt-2 "> {{ error }}</ p >
74+ }
75+
76+ < a routerLink ="/sign-in/forgot-password " class ="text-sm text-blue mt-4 ">
77+ Forgot password?
78+ </ a >
79+
80+ < button
81+ type ="button "
82+ class ="text-sm text-gray-500 mt-4 text-left "
83+ (click) ="toggleMode() "
84+ >
85+ Don't have an account? Sign up
86+ </ button >
87+ </ form >
88+ }
89+
90+ <!-- Register Form (email only) -->
91+ @if (mode === 'register') {
92+ < div class ="flex flex-col my-12 ">
93+ @if (success$ | async; as success) {
94+ < div class ="text-center ">
95+ < p class ="text-green-600 mb-4 "> {{ success }}</ p >
96+ < button
97+ type ="button "
98+ class ="text-sm text-gray-500 "
99+ (click) ="toggleMode() "
100+ >
101+ Back to sign in
102+ </ button >
103+ </ div >
104+ } @else {
105+ < form [formGroup] ="registerForm " (ngSubmit) ="submitRegister() ">
106+ < div class ="flex flex-col my-2 ">
107+ < label class ="mb-1 text-sm " for ="email "> E-mail</ label >
108+ < input
109+ class ="input-outline mb-0 "
110+ type ="email "
111+ formControlName ="email "
112+ placeholder ="you@example.com "
113+ autocomplete ="email "
114+ />
115+ < span class ="text-xs pb-2 text-red ">
116+ < form-error [control] ="registerForm.get('email') "> </ form-error >
117+ </ span >
118+ </ div >
119+
120+ < p class ="text-xs text-gray-500 mb-4 ">
121+ We'll send you an email to set your password.
122+ </ p >
123+
124+ < button
125+ class ="btn-blue shadow w-64 mt-2 "
126+ [disabled] ="registerForm.touched && registerForm.invalid || (loading$ | async) "
127+ type ="submit "
128+ >
129+ @if (loading$ | async) {
130+ < span > Creating account...</ span >
131+ } @else {
132+ Create account
133+ }
134+ </ button >
135+
136+ @if (error$ | async; as error) {
137+ < p class ="text-red text-sm mt-2 "> {{ error }}</ p >
138+ }
139+
140+ < button
141+ type ="button "
142+ class ="text-sm text-gray-500 mt-4 text-left "
143+ (click) ="toggleMode() "
144+ >
145+ Already have an account? Sign in
146+ </ button >
147+ </ form >
148+ }
53149 </ div >
54- < button class ="btn-blue shadow w-64 mt-2 " [disabled] ="form.touched && form.invalid " type ="submit ">
55- Sign in
56- </ button >
57- @if (error) {
58- < p class ="text-red "> Login failed</ p >
59- }
60- </ form >
150+ }
61151 }
152+
62153 @if (!ctx.displayPassForm) {
63154 < div class ="flex flex-col mx-auto my-12 ">
64155 < form action ="/api/v1/openid/github " method ="post ">
@@ -68,20 +159,21 @@ <h2 class="text-xl font-semibold lg:text-2xl">Sign in</h2>
68159 < path
69160 class ="transition-colors dark:fill-white "
70161 d ="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z "
71- />
162+ />
72163 </ svg >
73164 < span > Sign in with Github</ span >
74165 </ button >
75166 </ form >
76167 </ div >
77168 }
169+
78170 @if (allowPassword) {
79171 < button
80172 class ="text-sm text-gray-500 text-center w-full "
81173 type ="button "
82174 (click) ="ctx.displayPassForm = !ctx.displayPassForm "
83- >
84- Sign in using {{ ctx.displayPassForm ? 'Github' : 'password ' }}
175+ >
176+ Sign in using {{ ctx.displayPassForm ? 'Github' : 'email ' }}
85177 </ button >
86178 }
87179 </ div >
0 commit comments