@@ -12,6 +12,7 @@ export class ProfileComponent {
1212 @Prop ( ) url : string ;
1313 @State ( ) user : any ;
1414 @State ( ) password : string = "" ;
15+ @State ( ) repassword : string = "" ;
1516 @State ( ) name : string = "" ;
1617 @State ( ) error :any = null ;
1718
@@ -26,12 +27,16 @@ export class ProfileComponent {
2627 if ( this . name === "" ) {
2728 this . error = "User name is empty"
2829 }
29- if ( this . password . length < 7 ) {
30+ else if ( this . password . length < 7 ) {
3031 this . error = "Password length is less than 7 characters"
3132 }
3233 else if ( ! this . password . match ( / ( [ ! , % , & , @ , # , $ , ^ , * , ? , _ , ~ ] ) / ) ) {
3334 this . error = "Password does not contain any special character"
34- } else {
35+ }
36+ else if ( this . password !== this . repassword ) {
37+ this . error = "Password does not match with re-entered password"
38+ }
39+ else {
3540 try {
3641 await axios
3742 . put ( `${ this . url } api/users/password` , {
@@ -63,6 +68,9 @@ export class ProfileComponent {
6368 passwordHandler ( e ) {
6469 this . password = e . target . value ;
6570 }
71+ repasswordHandler ( e ) {
72+ this . repassword = e . target . value ;
73+ }
6674 nameChangeHandler ( e ) {
6775 this . name = e . target . value ;
6876 }
@@ -112,6 +120,20 @@ export class ProfileComponent {
112120 < p class = "text-gray-600 text-xs italic" > Enter updated password</ p >
113121 </ div >
114122 </ div >
123+ < div class = "flex flex-wrap -mx-3 mb-6" >
124+ < div class = "w-full px-3" >
125+ < label class = "block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" > Re-enter Password</ label >
126+ < input
127+ onInput = { e => this . repasswordHandler ( e ) }
128+ class = "appearance-none block w-full bg-white text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
129+ id = "grid-password"
130+ type = "password"
131+ placeholder = "******************"
132+ value = { this . repassword }
133+ />
134+ < p class = "text-gray-600 text-xs italic" > Re-enter the password</ p >
135+ </ div >
136+ </ div >
115137 < div class = "flex flex-row-reverse -mx-3 mb-6 " >
116138 < button class = "border-2 border-gray-800 w-32 py-4 px-6 mx-4 font-medium text-lg text-white bg-gray-500 rounded-lg hover:bg-gray-400" > Update</ button >
117139 { this . error ?< p class = "rounded-lg mx-4 my-2 px-3 py-2 bg-red-200 text-red-800 border-l-4 border-red-600 w-full" > { this . error } </ p > :null }
0 commit comments