6
6
<div :class =" $style.formContainer" slot =" basic" >
7
7
<form :class =" $style.form" @submit.prevent =" submitForm" >
8
8
<div :class =" $style.card" >
9
- <h3 >Reset Password</h3 >
9
+ <h3 >Change Password</h3 >
10
10
<div :class =" $style.fieldsContainer" >
11
11
<div :class =" $style.field" >
12
- <label for =" currentPasswd" :class =" $style.label" >current password</label >
13
- <input
14
- type =" password"
15
- id =" currentPasswd"
16
- :class =" $style.field"
17
- v-model =" currentPasswd"
18
- required
19
- >
12
+ <label for =" old__password" :class =" $style.label" >current password</label >
13
+ <span :class =" $style.fieldWrapper" >
14
+ <input
15
+ type =" password"
16
+ id =" old__password"
17
+ :class =" $style.field"
18
+ v-model =" currentPasswd"
19
+ required
20
+ >
21
+ <i
22
+ class =" fas"
23
+ :class =" isPasswordVisible('old__password') ? 'fa-eye' : 'fa-eye-slash'"
24
+ @click =" togglePasswordVisibility('old__password')"
25
+ ></i >
26
+ </span >
20
27
</div >
21
28
<div :class =" $style.field" >
22
- <label for =" newPasswd" :class =" $style.label" >new password</label >
23
- <input
24
- type =" password"
25
- id =" newPasswd"
26
- :class =" $style.field"
27
- v-model =" newPasswd"
28
- required
29
- >
30
- </div >
31
- <div :class =" $style.field" >
32
- <label for =" confirmPasswd" :class =" $style.label" >retype new password</label >
33
- <input
34
- type =" password"
35
- id =" confirmPasswd"
36
- :class =" $style.field"
37
- v-model =" confirmPasswd"
38
- required
39
- >
29
+ <label for =" new__password" :class =" $style.label" >new password</label >
30
+ <span :class =" $style.fieldWrapper" >
31
+ <input
32
+ type =" password"
33
+ id =" new__password"
34
+ :class =" $style.field"
35
+ v-model =" newPasswd"
36
+ required
37
+ >
38
+ <i
39
+ class =" fas"
40
+ :class =" isPasswordVisible('new__password') ? 'fa-eye' : 'fa-eye-slash'"
41
+ @click =" togglePasswordVisibility('new__password')"
42
+ ></i >
43
+ </span >
40
44
</div >
41
45
</div >
42
46
<div :class =" $style.btnStyle" >
53
57
</div >
54
58
</template >
55
59
56
- <script >
60
+ <script >
61
+ import firebase from " firebase" ;
62
+ import API from " @js/api" ;
63
+
57
64
import AppBar from " @components/Menu/AppBar" ;
58
65
import Footer from " @components/Footer" ;
59
66
import TabLayout from " @components/layouts/TabLayout" ;
60
- import firebase from " firebase" ;
61
- import API from " @js/api" ;
62
67
63
68
export default {
64
69
components: {
@@ -70,27 +75,45 @@ export default {
70
75
return {
71
76
currentPasswd: " " ,
72
77
newPasswd: " " ,
73
- confirmPasswd : " "
78
+ __stubbed : 0
74
79
};
75
80
},
81
+ computed: {
82
+ isPasswordVisible () {
83
+ this .$data .__stubbed ; // To make this computed data reactive.
84
+ return inputId => {
85
+ const inputElem = document .getElementById (inputId);
86
+ if (inputElem) return inputElem .type !== " password" ;
87
+ };
88
+ }
89
+ },
76
90
methods: {
77
91
submitForm () {
78
92
var user = firebase .auth ().currentUser ;
79
- if (this .newPasswd == this .confirmPasswd )
80
- user
81
- .reauthenticateAndRetrieveDataWithCredential (this .currentPasswd )
82
- .then (_ => {
83
- user
84
- .updatePassword (this .newPassword )
85
- .then (_ => {})
86
- .catch (console .log );
87
- })
88
- .catch (console .log );
89
- else alert (" Passwords do not match." );
93
+ user
94
+ .reauthenticateAndRetrieveDataWithCredential (this .currentPasswd )
95
+ .then (_ => {
96
+ user
97
+ .updatePassword (this .newPassword )
98
+ .then (_ => {
99
+ this .$toasted .global .success ({
100
+ message: ` Successfully updated password!`
101
+ });
102
+ })
103
+ .catch (err => {
104
+ this .$toasted .global .error_post ({ message: err .message });
105
+ });
106
+ })
107
+ .catch (err => {
108
+ this .$toasted .global .error_post ({ message: err .message });
109
+ });
110
+ },
111
+ togglePasswordVisibility (inputId ) {
112
+ const inputElem = document .getElementById (inputId);
113
+ inputElem .type = inputElem .type === " password" ? " text" : " password" ;
114
+ this .$data .__stubbed ++ ;
90
115
}
91
- },
92
- created () {},
93
- mounted () {}
116
+ }
94
117
};
95
118
</script >
96
119
<style module lang="stylus">
@@ -213,6 +236,18 @@ export default {
213
236
margin-bottom : 15px ;
214
237
}
215
238
239
+ .fieldWrapper {
240
+ width : 100% ;
241
+ position : relative ;
242
+
243
+ i {
244
+ top : 0 ;
245
+ right : 7px ;
246
+ position : absolute ;
247
+ cursor : pointer ;
248
+ }
249
+ }
250
+
216
251
option {
217
252
color : black ;
218
253
}
@@ -262,32 +297,6 @@ export default {
262
297
}
263
298
}
264
299
}
265
-
266
- .social {
267
- width : 100% ;
268
- max-width : 600px ;
269
- margin : auto ;
270
- text-align : center ;
271
- padding : 5px ;
272
- margin-top : 20px ;
273
- border : 0 ;
274
- border-top : 1px solid $chartreuse ;
275
-
276
- .socialButton {
277
- background-color : Transparent ;
278
- background-repeat : no-repeat ;
279
- border : none ;
280
- cursor : pointer ;
281
- overflow : hidden ;
282
- outline : none ;
283
-
284
- img {
285
- margin : 10px ;
286
- width : 40px ;
287
- height : 40px ;
288
- }
289
- }
290
- }
291
300
}
292
301
}
293
302
0 commit comments