Skip to content

Commit

Permalink
add password update option (#12635)
Browse files Browse the repository at this point in the history
  • Loading branch information
pragatimodi authored May 6, 2024
1 parent 18157dc commit e81bfdb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ enum UserAction: String {
case updateDisplayName = "Display Name"
case updatePhoneNumber = "Phone Number"
case refreshUserInfo = "Refresh User Info"
case updatePassword = "Update Password"
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extension User: DataSourceProvidable {
Item(title: UserAction.signOut.rawValue, textColor: .systemBlue),
Item(title: UserAction.link.rawValue, textColor: .systemBlue, hasNestedContent: true),
Item(title: UserAction.requestVerifyEmail.rawValue, textColor: .systemBlue),
Item(title: UserAction.updatePassword.rawValue, textColor: .systemBlue),
Item(title: UserAction.tokenRefresh.rawValue, textColor: .systemBlue),
Item(title: UserAction.delete.rawValue, textColor: .systemRed),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class UserViewController: UIViewController, DataSourceProviderDelegate {
case .updateEmail:
presentEditUserInfoController(for: actionName, to: updateUserEmail)

case .updatePassword:
presentEditUserInfoController(for: actionName, to: updatePassword)

case .updateDisplayName:
presentEditUserInfoController(for: actionName, to: updateUserDisplayName)

Expand Down Expand Up @@ -165,6 +168,19 @@ class UserViewController: UIViewController, DataSourceProviderDelegate {
})
}

public func updatePassword(to newPassword: String) {
user?.updatePassword(to: newPassword, completion: {
error in
if let error = error {
print("Update password failed. \(error)", error)
return
} else {
print("Password updated!")
}
self.updateUI()
})
}

public func updatePhotoURL(to newPhotoURL: String) {
guard let newPhotoURL = URL(string: newPhotoURL) else {
print("Could not create new photo URL!")
Expand Down

0 comments on commit e81bfdb

Please sign in to comment.