11<template >
22 <AuthForm
3- v-if =" ! $route .query .token "
3+ v-if =" ! emailSentSuccess && ! $route .query .uid "
44 v-slot =" { invalid } "
55 error-header="Error sending reset link, please fix the following errors:"
66 :errors =" errors "
2323 <AuthSubmit :disabled =" invalid " >Send Reset Link</AuthSubmit >
2424 </AuthForm >
2525
26+ <AuthForm
27+ v-else-if =" emailSentSuccess "
28+ class="gap-5 text-2xl font-bold text-white place-items-center"
29+ >
30+ <h1 class =" text-3xl" >Reset Link Has Been Sent!</h1 >
31+ <p >Please check your spam folder if you cannot find the email.</p >
32+ <font-awesome-icon
33+ :icon =" ['fas', 'fa-face-smile-beam']"
34+ class =" text-[10rem] my-10"
35+ />
36+ </AuthForm >
37+
2638 <AuthForm
2739 v-else-if =" ! passwordResetSuccess "
2840 v-slot =" { invalid } "
3143 @submit =" resetPassword "
3244 >
3345 <div class =" mt-1 mb-3" >
46+ <p v-if =" uid !== ''" class =" text-center text-white" >
47+ Resetting password for {{ uid }}
48+ </p >
3449 <p class =" text-center text-white" >Please enter <wbr />a new password.</p >
3550 </div >
3651 <InputField
4863
4964 <AuthForm
5065 v-else
51- class="place-items-center gap-5 font-bold text-2xl text-white "
66+ class="gap-5 text-2xl font-bold text-white place-items-center "
5267 >
5368 <h1 class =" text-3xl" >Congratulations!</h1 >
5469 <p >
5570 Your password has been reset. Now you <wbr />can login with your new
56- password
71+ password!
5772 </p >
5873 <font-awesome-icon
5974 :icon =" ['fas', 'fa-face-smile-beam']"
@@ -77,10 +92,12 @@ export default {
7792 data : () => ({
7893 title: ' Reset Password' ,
7994 passwordResetSuccess: false ,
95+ emailSentSuccess: false ,
96+ uid: ' ' ,
8097 errors: [],
8198
8299 emailField: {
83- name: ' email ' ,
100+ name: ' Email ' ,
84101 type: ' email' ,
85102 index: 0 ,
86103 id: ' email' ,
@@ -89,32 +106,84 @@ export default {
89106
90107 fields: [
91108 {
92- name: ' password ' ,
109+ name: ' Password ' ,
93110 type: ' password' ,
94111 index: count++ ,
95112 id: ' password' ,
96113 rules: ' required|min:6' ,
97114 },
98115 {
99- name: ' confirm password ' ,
116+ name: ' Confirm Password ' ,
100117 type: ' password' ,
101118 index: count++ ,
102119 id: ' confirm' ,
103120 rules: ' required|password:@password' ,
104121 },
105122 ],
106123 }),
124+
107125 head () {
108126 return {
109127 title: this .title ,
110128 };
111129 },
130+
131+ async mounted () {
132+ const rawUid = this .$route .query .uid ;
133+ const rawToken = this .$route .query .token ;
134+
135+ if (! rawUid) {
136+ return ;
137+ }
138+
139+ const formattedUid =
140+ rawUid .charAt (rawUid .length - 1 ) === ' /'
141+ ? rawUid .substring (0 , rawUid .length - 1 )
142+ : rawUid;
143+
144+ const formattedToken =
145+ rawUid .charAt (rawUid .length - 1 ) === ' /'
146+ ? rawUid .substring (0 , rawUid .length - 1 )
147+ : rawUid;
148+
149+ const url =
150+ ' auth/reset/' + ` ?token=${ this .formattedToken } &uid=${ this .formattedUid } /` ;
151+
152+ try {
153+ this .uid = atob (formattedUid);
154+ console .log (this .uid );
155+ } catch (err) {
156+ console .log (err);
157+ this .errors = { Errors: [' email UID is invalid' ] };
158+ return ;
159+ }
160+
161+ await this .$axios
162+ .$get (url)
163+ .then ((resp ) => (this .emailSentSuccess = true ))
164+ .catch ((error ) => {
165+ this .errors = error .response .data ;
166+ console .log (error .response .data );
167+ });
168+ },
169+
112170 methods: {
113- onSubmit () {
114- alert (' submitted' );
171+ async sendResetLink (e ) {
172+ const elements = e .target .elements ;
173+ const data = {
174+ email: elements .Email .value ,
175+ };
176+
177+ const url = ' auth/reset/email/' ;
178+ await this .$axios
179+ .$post (url, data)
180+ .then ((resp ) => (this .passwordResetSuccess = true ))
181+ .catch ((error ) => {
182+ this .errors = error .response .data ;
183+ console .log (error .response .data );
184+ });
115185 },
116186
117- sendResetLink () {},
118187 resetPassword () {},
119188 },
120189};
0 commit comments