File tree Expand file tree Collapse file tree 3 files changed +60
-4
lines changed
Expand file tree Collapse file tree 3 files changed +60
-4
lines changed Original file line number Diff line number Diff line change 117117
118118 .auth-sub-container-error {
119119 @apply bg-red-500;
120- @apply py -4;
120+ @apply p -4;
121121 @apply flex;
122122 @apply justify-center;
123123 @apply text-center;
166166 @apply mt-4;
167167 }
168168
169+ .auth-sub-container-content-submit-button : active , .auth-sub-container-content-submit-button : focus {
170+ outline : none;
171+ }
172+
169173 .auth-sub-container-content-button {
170174 @apply bg-purple-matcha;
171175 @apply w-full;
Original file line number Diff line number Diff line change 11<template >
22 <!-- eslint-disable max-len -->
33 <div class =" auth-container" >
4+ <div class =" auth-sub-container-error mb-4" v-if =" error.happened" >
5+ <h1 class =" auth-sub-container-error-message" >{{error.message}}</h1 >
6+ </div >
47 <div class =" auth-sub-container" >
58 <div class =" auth-sub-container-content" v-if =" !forgotPasswordEmailSent" >
69 <img src =" ../../assets/auth/lock.png" class =" h-12" >
@@ -40,10 +43,32 @@ export default {
4043 email: ' ' ,
4144 },
4245 forgotPasswordEmailSent: false ,
46+ error: {
47+ happened: false ,
48+ message: ' ' ,
49+ },
4350 }),
4451 methods: {
45- onSubmit () {
46- this .forgotPasswordEmailSent = true ;
52+ async onSubmit () {
53+ try {
54+ this .clearError ();
55+ const passwordForgotResponse = await this .$http .post (' /auth/password/forgot' , this .formData );
56+ if (passwordForgotResponse .status !== 200 ) {
57+ this .displayError (' Something went wrong on our end. We are sorry. Please, try again later.' );
58+ return ;
59+ }
60+ this .forgotPasswordEmailSent = true ;
61+ } catch (error) {
62+ this .displayError (' Something went wrong on our end. We are sorry. Please, try again later.' );
63+ }
64+ },
65+ clearError () {
66+ this .error .message = ' ' ;
67+ this .error .happened = false ;
68+ },
69+ displayError (message ) {
70+ this .error .message = message;
71+ this .error .happened = true ;
4772 },
4873 },
4974};
Original file line number Diff line number Diff line change 11<template >
22 <!-- eslint-disable max-len -->
33 <div class =" auth-container" >
4+ <div class =" auth-sub-container-error mb-4" v-if =" error.happened" >
5+ <h1 class =" auth-sub-container-error-message" >{{error.message}}</h1 >
6+ </div >
47 <div class =" auth-sub-container" >
58 <div class =" auth-sub-container-content" v-if =" !passwordHasBeenReset" >
69 <img src =" ../../assets/auth/refresh.png" class =" h-12" >
2932<script >
3033
3134export default {
35+ async beforeMount () {
36+ await this .checkToken ();
37+ },
3238 data : () => ({
3339 formData: {
3440 password: ' ' ,
3541 },
3642 passwordHasBeenReset: false ,
43+ error: {
44+ happened: false ,
45+ message: ' ' ,
46+ },
3747 }),
3848 methods: {
3949 passwordErrorHandler (error ) {
@@ -42,9 +52,26 @@ export default {
4252 }
4353 return ' This password is too easy to guess' ;
4454 },
45- onSubmit () {
55+ async onSubmit () {
56+ const resetPasswordResponse = await this .$http .post (' /auth/password/reset' , this .formData );
57+ if (resetPasswordResponse .status !== 200 ) {
58+ this .error .message = resetPasswordResponse .data .error .message ;
59+ this .error .happened = true ;
60+ return ;
61+ }
4662 this .passwordHasBeenReset = true ;
4763 },
64+ async checkToken () {
65+ const { token } = this .$route .query ;
66+ if (! token) {
67+ await this .$router .push (' /accounts/password/reseterror' );
68+ return ;
69+ }
70+ const tokenCheck = await this .$http .post (' /auth/password/check_token' , { token });
71+ if (tokenCheck .status !== 200 ) {
72+ await this .$router .push (' /accounts/password/reseterror' );
73+ }
74+ },
4875 },
4976};
5077
You can’t perform that action at this time.
0 commit comments