aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example
diff options
context:
space:
mode:
authorGravatar Zsika Phillip <protocol86@users.noreply.github.com>2017-10-25 16:49:59 -0700
committerGravatar GitHub <noreply@github.com>2017-10-25 16:49:59 -0700
commit390d600b53432f33558e63ef05621ec57f03f07f (patch)
treea24dc75df9c8616608155895c93c3ba8392941bc /Example
parent8bdce1dfa4cd8377e7b90b21e973608e7c688642 (diff)
Improve swift sample app (#409)
* Updates the sign-in methods on Swift Sample Updates the sign-in, reauth and link with credential methods on Swift Sample to use the recommended Auth result paradigm. * adds missing space after { * addresses comments
Diffstat (limited to 'Example')
-rw-r--r--Example/Auth/SwiftSample/ViewController.swift18
1 files changed, 13 insertions, 5 deletions
diff --git a/Example/Auth/SwiftSample/ViewController.swift b/Example/Auth/SwiftSample/ViewController.swift
index a35faeb..4d75358 100644
--- a/Example/Auth/SwiftSample/ViewController.swift
+++ b/Example/Auth/SwiftSample/ViewController.swift
@@ -223,9 +223,10 @@ final class ViewController: UIViewController, UITextFieldDelegate, AuthUIDelegat
}
case .signInWithCredential:
getCredential() { credential in
- Auth.auth().signIn(with: credential) { user, error in
+ Auth.auth().signInAndRetrieveData(with: credential) { authData, error in
self.ifNoError(error) {
- self.showAlert(title: "Signed In With Credential", message: user?.textDescription)
+ self.showAlert(title: "Signed In With Credential",
+ message: authData?.user.textDescription)
}
}
}
@@ -276,8 +277,14 @@ final class ViewController: UIViewController, UITextFieldDelegate, AuthUIDelegat
}
case .reauthenticate:
getCredential() { credential in
- self.user!.reauthenticate(with: credential) { error in
+ self.user!.reauthenticateAndRetrieveData(with: credential) { authData, error in
self.ifNoError(error) {
+ if (authData?.user.uid != self.user?.uid) {
+ let message = "The reauthenticated user must be the same as the original user"
+ self.showAlert(title: "Reauthention error",
+ message: message)
+ return
+ }
self.showAlert(title: "Reauthenticated", message: self.user?.textDescription)
}
}
@@ -290,9 +297,10 @@ final class ViewController: UIViewController, UITextFieldDelegate, AuthUIDelegat
}
case .linkWithCredential:
getCredential() { credential in
- self.user!.link(with: credential) { user, error in
+ self.user!.linkAndRetrieveData(with: credential) { authData, error in
self.ifNoError(error) {
- self.showAlert(title: "Linked With Credential", message: user?.textDescription)
+ self.showAlert(title: "Linked With Credential",
+ message: authData?.user.textDescription)
}
}
}