diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/UserActions.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/UserActions.swift index da8e7721971..a2d87183c4a 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/UserActions.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/UserActions.swift @@ -24,4 +24,5 @@ enum UserAction: String { case updateDisplayName = "Display Name" case updatePhoneNumber = "Phone Number" case refreshUserInfo = "Refresh User Info" + case updatePassword = "Update Password" } diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift index 4ce45df4020..e41a40df15a 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift @@ -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), ] diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/UserViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/UserViewController.swift index 651c2e5f6ef..77ce4a9c792 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/UserViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/UserViewController.swift @@ -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) @@ -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!")