76
76
<v-card class =" px-5 py-5" style =" border-radius : 15px ;" >
77
77
<v-card-text >
78
78
<v-form
79
+ @submit.prevent
79
80
ref =" signInForm"
80
81
lazy-validation
81
82
v-model =" signInFormValid"
99
100
</h2 >
100
101
101
102
<h2 v-else class =" text-center pt-4 pb-6" >
102
- Log in to your account
103
+ Enter to your account
103
104
</h2 >
104
105
105
106
<v-alert
139
140
{{ $t('Use recovery code') }}
140
141
</a >
141
142
142
- <a
143
+ <v-btn
144
+ :width =" 200"
145
+ small
146
+ :disabled =" verificationEmailSending"
147
+ color =" primary"
143
148
v-if =" verificationMethod === 'email'"
144
149
@click =" resendEmailVerification()"
145
150
>
146
- {{ $t('Resend code to email') }}
147
- </a >
151
+ {{
152
+ verificationEmailSending
153
+ ? $t('Email sending...')
154
+ : $t('Resend code to email')
155
+ }}
156
+ </v-btn >
148
157
</div >
149
158
</div >
150
159
180
189
</div >
181
190
182
191
<div v-else >
183
- <v-text-field
184
- v-model =" username"
185
- v-bind:label =' $t("username")'
186
- :rules =" [v => !!v || $t('username_required')]"
187
- required
188
- :disabled =" signInProcess"
189
- v-if =" loginWithPassword"
190
- data-testid =" auth-username"
191
- ></v-text-field >
192
192
193
- <v-text-field
194
- v-model =" password"
195
- :label =" $t('password')"
196
- :rules =" [v => !!v || $t('password_required')]"
197
- type =" password"
198
- required
199
- :disabled =" signInProcess"
200
- @keyup.enter.native =" signIn"
201
- style =" margin-bottom : 20px ;"
202
- v-if =" loginWithPassword"
203
- data-testid =" auth-password"
204
- ></v-text-field >
193
+ <div v-if =" loginWithPassword" >
194
+ <v-text-field
195
+ v-model =" username"
196
+ v-bind:label =' $t("username")'
197
+ :rules =" [v => !!v || $t('username_required')]"
198
+ required
199
+ :disabled =" signInProcess"
200
+ data-testid =" auth-username"
201
+ ></v-text-field >
202
+
203
+ <v-text-field
204
+ v-model =" password"
205
+ :label =" $t('password')"
206
+ :rules =" [v => !!v || $t('password_required')]"
207
+ type =" password"
208
+ required
209
+ :disabled =" signInProcess"
210
+ @keyup.enter.native =" signIn"
211
+ style =" margin-bottom : 20px ;"
212
+ data-testid =" auth-password"
213
+ ></v-text-field >
205
214
206
- <v-btn
207
- large
208
- color =" primary"
209
- @click =" signIn"
210
- :disabled =" signInProcess"
211
- block
212
- v-if =" loginWithPassword"
213
- rounded
214
- data-testid =" auth-signin"
215
- >
216
- {{ $t('signIn') }}
217
- </v-btn >
215
+ <v-btn
216
+ large
217
+ color =" primary"
218
+ @click =" signIn"
219
+ :disabled =" signInProcess"
220
+ block
221
+ rounded
222
+ data-testid =" auth-signin"
223
+ >
224
+ {{ $t('signIn') }}
225
+ </v-btn >
226
+
227
+ </div >
228
+
229
+ <div v-else >
230
+ <v-text-field
231
+ v-model =" email"
232
+ :label =" $t('Email')"
233
+ :rules =" [v => !!v || $t('email_required')]"
234
+ type =" email"
235
+ required
236
+ :disabled =" signInProcess"
237
+ @keyup.enter.native =" signInWithEmail"
238
+ style =" margin-bottom : 20px ;"
239
+ data-testid =" auth-password"
240
+ outlined
241
+ class =" mb-0"
242
+ ></v-text-field >
243
+
244
+ <v-btn
245
+ large
246
+ color =" primary"
247
+ @click =" signInWithEmail"
248
+ :disabled =" signInProcess"
249
+ block
250
+ rounded
251
+ data-testid =" auth-signin-with-eamil"
252
+ >
253
+ <v-icon
254
+ left
255
+ dark
256
+ >
257
+ mdi-email
258
+ </v-icon >
259
+
260
+ {{ $t('Continue with Email') }}
261
+ </v-btn >
262
+ </div >
218
263
219
264
<div
220
265
class =" auth__divider"
221
- v-if =" loginWithPassword && oidcProviders.length > 0"
266
+ v-if =" oidcProviders.length > 0"
222
267
>or</div >
223
268
224
269
<v-btn
243
288
{{ provider.name }}
244
289
</v-btn >
245
290
246
- <div class =" text-center mt-6" v-if =" loginWithPassword" >
291
+ <div class =" text-center mt-6" v-if =" loginWithPassword && false " >
247
292
<a @click =" loginHelpDialog = true" >{{ $t('dontHaveAccountOrCantSignIn') }}</a >
248
293
</div >
249
294
@@ -300,6 +345,8 @@ export default {
300
345
password: null ,
301
346
username: null ,
302
347
348
+ email: null ,
349
+
303
350
loginHelpDialog: null ,
304
351
305
352
oidcProviders: [],
@@ -311,6 +358,8 @@ export default {
311
358
verificationCode: null ,
312
359
verificationMethod: null ,
313
360
recoveryCode: null ,
361
+ verificationEmailSending: false ,
362
+
314
363
};
315
364
},
316
365
@@ -336,7 +385,29 @@ export default {
336
385
337
386
methods: {
338
387
async resendEmailVerification () {
339
- // TODO: resend email verification code
388
+ if (this .verificationEmailSending ) {
389
+ return ;
390
+ }
391
+
392
+ this .verificationEmailSending = true ;
393
+ try {
394
+ (await axios ({
395
+ method: ' post' ,
396
+ url: ' /api/auth/login/email/resend' ,
397
+ responseType: ' json' ,
398
+ }));
399
+ EventBus .$emit (' i-snackbar' , {
400
+ color: ' success' ,
401
+ text: ' Verification email sent successfully.' ,
402
+ });
403
+ } catch (e) {
404
+ EventBus .$emit (' i-snackbar' , {
405
+ color: ' error' ,
406
+ text: getErrorMessage (e),
407
+ });
408
+ } finally {
409
+ this .verificationEmailSending = false ;
410
+ }
340
411
},
341
412
342
413
async loadLoginData () {
@@ -439,6 +510,7 @@ export default {
439
510
}
440
511
441
512
this .signInProcess = true ;
513
+
442
514
try {
443
515
await axios ({
444
516
method: ' post' ,
@@ -451,11 +523,35 @@ export default {
451
523
document .location = document .baseURI + window .location .search ;
452
524
} catch (err) {
453
525
this .signInError = getErrorMessage (err);
454
- // if (err.response.status === 401) {
455
- // this.signInError = this.$t('Incorrect verification code.');
456
- // } else {
457
- // this.signInError = getErrorMessage(err);
458
- // }
526
+ } finally {
527
+ this .signInProcess = false ;
528
+ }
529
+ },
530
+
531
+ async signInWithEmail () {
532
+ this .signInError = null ;
533
+
534
+ if (! this .$refs .signInForm .validate ()) {
535
+ return ;
536
+ }
537
+
538
+ this .signInProcess = true ;
539
+ try {
540
+ await axios ({
541
+ method: ' post' ,
542
+ url: ' /api/auth/login/email' ,
543
+ responseType: ' json' ,
544
+ data: {
545
+ email: this .email ,
546
+ },
547
+ });
548
+ document .location = document .baseURI + window .location .search ;
549
+ } catch (err) {
550
+ if (err .response .status === 401 ) {
551
+ this .signInError = this .$t (' incorrectEmail' );
552
+ } else {
553
+ this .signInError = getErrorMessage (err);
554
+ }
459
555
} finally {
460
556
this .signInProcess = false ;
461
557
}
0 commit comments