Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
getme
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
amal
getme
Commits
4995603e
Commit
4995603e
authored
Feb 05, 2020
by
muhsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added change password
parent
30081a1f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
12 deletions
+84
-12
changedetails.page.html
src/app/changedetails/changedetails.page.html
+20
-5
changedetails.page.ts
src/app/changedetails/changedetails.page.ts
+17
-7
update.service.ts
src/config/update.service.ts
+47
-0
No files found.
src/app/changedetails/changedetails.page.html
View file @
4995603e
...
@@ -72,9 +72,22 @@
...
@@ -72,9 +72,22 @@
<div
class=
"row"
>
<div
class=
"row"
>
<h6>
Change Password
</h6>
<h6>
Change Password
</h6>
</div>
</div>
<!-- <div class="row">
<div
class=
"row"
>
<input class="" type="password" placeholder="Current Password" />
<input
</div> -->
class=
""
type=
"password"
minlength=
"6"
#
currentPassword=
"ngModel"
[(
ngModel
)]="
updatePassword
.
currentPassword
"
name=
"currentPassword"
placeholder=
"Current Password"
/>
<div
*
ngIf=
"currentPassword.errors && currentPassword.errors.minlength"
>
Password must be at least 6 characters
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<input
<input
class=
""
class=
""
...
@@ -83,6 +96,7 @@
...
@@ -83,6 +96,7 @@
type=
"password"
type=
"password"
placeholder=
"New Password"
placeholder=
"New Password"
minlength=
"6"
minlength=
"6"
[
required
]="
currentPassword
?
true:
false
"
#
password=
"ngModel"
#
password=
"ngModel"
/>
/>
<div
*
ngIf=
"password.errors && password.errors.minlength"
>
<div
*
ngIf=
"password.errors && password.errors.minlength"
>
...
@@ -96,10 +110,11 @@
...
@@ -96,10 +110,11 @@
[(
ngModel
)]="
updatePassword
.
confirmPassword
"
[(
ngModel
)]="
updatePassword
.
confirmPassword
"
name=
"confirmPassword"
name=
"confirmPassword"
type=
"password"
type=
"password"
[
required
]="
currentPassword
?
true:
false
"
placeholder=
"Confirm Password"
placeholder=
"Confirm Password"
/>
/>
<div
*
ngIf=
""
>
<div
*
ngIf=
"
confirmPassword.errors
"
>
Password should match
{{confPasswordErr}}
</div>
</div>
</div>
</div>
</div>
</div>
...
...
src/app/changedetails/changedetails.page.ts
View file @
4995603e
...
@@ -17,6 +17,7 @@ export class ChangedetailsPage implements OnInit {
...
@@ -17,6 +17,7 @@ export class ChangedetailsPage implements OnInit {
name
:
''
,
name
:
''
,
phone
:
''
phone
:
''
};
};
confPasswordErr
:
string
;
updatePassword
:
UpdatePassword
=
{
updatePassword
:
UpdatePassword
=
{
password
:
''
,
password
:
''
,
...
@@ -62,19 +63,28 @@ export class ChangedetailsPage implements OnInit {
...
@@ -62,19 +63,28 @@ export class ChangedetailsPage implements OnInit {
console
.
log
(
form
.
value
);
console
.
log
(
form
.
value
);
if
(
form
.
valid
)
{
if
(
form
.
valid
)
{
// Change Password
// Change Password
if
(
form
.
value
.
password
)
{
if
(
form
.
value
.
currentPassword
&&
form
.
value
.
password
)
{
if
(
form
.
value
.
password
===
form
.
value
.
confirmPassword
)
{
if
(
form
.
value
.
password
&&
form
.
value
.
password
===
form
.
value
.
confirmPassword
)
{
// this.register.updateData(form.value, this.userData.uid);
// this.register.updateData(form.value, this.userData.uid);
// this.register.updatePassword(form.value.password);
this
.
register
.
updatePassword
(
console
.
log
(
'Password Changed and profile updated'
);
form
.
value
.
currentPassword
,
form
.
value
.
password
);
console
.
log
(
'Password Changed and profile updated'
),
form
.
value
;
}
else
{
}
else
{
console
.
log
(
'Password should match'
);
console
.
log
(
'Password should match'
);
this
.
confPasswordErr
=
'Password should match'
;
}
}
}
else
{
}
else
{
this
.
register
.
updateData
(
form
.
value
,
this
.
userData
);
//
this.register.updateData(form.value, this.userData);
console
.
log
(
'profile updated'
);
console
.
log
(
'profile updated'
,
form
.
value
);
}
}
console
.
log
(
'valid form values'
,
form
.
value
);
// console.log('valid form values', form.value);
}
else
{
console
.
log
(
form
);
}
}
}
}
}
}
src/config/update.service.ts
View file @
4995603e
...
@@ -48,6 +48,7 @@ export class UpdateService {
...
@@ -48,6 +48,7 @@ export class UpdateService {
// });
// });
}
}
// Update User Data
updateData
(
userData
:
UpdateUserDetails
,
oldData
:
User
)
{
updateData
(
userData
:
UpdateUserDetails
,
oldData
:
User
)
{
this
.
loader
=
true
;
this
.
loader
=
true
;
this
.
type
=
2
;
this
.
type
=
2
;
...
@@ -85,4 +86,50 @@ export class UpdateService {
...
@@ -85,4 +86,50 @@ export class UpdateService {
console
.
log
(
error
);
console
.
log
(
error
);
});
});
}
}
// Change user password
updatePassword
(
currentPassword
:
string
,
newPasswd
:
string
)
{
this
.
loader
=
true
;
let
currentUser
=
this
.
afAuth
.
auth
.
currentUser
;
// Gets current user
// Credential is required for re-authentication
const
credential
=
auth
.
EmailAuthProvider
.
credential
(
currentUser
.
email
,
currentPassword
);
// Re-authenticate user
currentUser
.
reauthenticateWithCredential
(
credential
)
.
then
(()
=>
{
currentUser
.
updatePassword
(
newPasswd
)
// Update password
.
then
(
success
=>
{
console
.
log
(
'password changed'
);
this
.
loader
=
false
;
this
.
service
.
showToast
(
'Password Changed!'
,
'top'
,
'my-toast'
,
1000
)
//success toast
.
then
(
res
=>
{
this
.
router
.
navigateByUrl
(
'profile'
);
this
.
loader
=
false
;
});
})
.
catch
(
error
=>
{
console
.
log
(
'something fishy'
);
this
.
service
.
showToast
(
'Something went wrong'
,
'top'
,
'my-toast'
,
1000
)
//failure toast
.
then
(
res
=>
{
this
.
loader
=
false
;
});
});
})
.
catch
(
error
=>
{
console
.
log
(
error
);
this
.
service
.
showToast
(
error
.
message
,
'top'
,
'my-error'
,
3000
)
//failure toast
.
then
(
res
=>
{
this
.
loader
=
false
;
});
});
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment