diff options
author | Zsika Phillip <protocol86@users.noreply.github.com> | 2018-04-25 21:50:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-25 21:50:19 -0700 |
commit | bd85f550931f89c82ebf77d53cbff049bfef9be8 (patch) | |
tree | 77ac278f2221fd1b7413bdc84d2c246669f82ae8 /Example | |
parent | 0748f265a6c95e2692f27ad59235521cb45e175d (diff) |
Adds new callback to createUse API (breaking change) (#1186)
Diffstat (limited to 'Example')
-rw-r--r-- | Example/Auth/Sample/MainViewController.m | 8 | ||||
-rw-r--r-- | Example/Auth/SwiftSample/ViewController.swift | 4 | ||||
-rw-r--r-- | Example/Auth/Tests/FIRAuthTests.m | 15 |
3 files changed, 16 insertions, 11 deletions
diff --git a/Example/Auth/Sample/MainViewController.m b/Example/Auth/Sample/MainViewController.m index 4c9ec13..0da28c8 100644 --- a/Example/Auth/Sample/MainViewController.m +++ b/Example/Auth/Sample/MainViewController.m @@ -1884,7 +1884,8 @@ static NSDictionary<NSString *, NSString *> *parseURL(NSString *urlString) { callback:(nullable FIRAuthResultCallback)callback { [[AppManager auth] createUserWithEmail:email password:password - completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { + completion:^(FIRAuthDataResult *_Nullable result, + NSError *_Nullable error) { if (error) { [self logFailure:@"sign-up with Email/Password failed" error:error]; if (callback) { @@ -1893,7 +1894,7 @@ static NSDictionary<NSString *, NSString *> *parseURL(NSString *urlString) { } else { [self logSuccess:@"sign-up with Email/Password succeeded."]; if (callback) { - callback(user, nil); + callback(result.user, nil); } } [self showTypicalUIForUserUpdateResultsWithTitle:@"Sign-In" error:error]; @@ -2803,7 +2804,8 @@ static NSDictionary<NSString *, NSString *> *parseURL(NSString *urlString) { [self showSpinner:^{ [[AppManager auth] createUserWithEmail:email password:password - completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { + completion:^(FIRAuthDataResult *_Nullable result, + NSError *_Nullable error) { if (error) { [self logFailure:@"create user failed" error:error]; } else { diff --git a/Example/Auth/SwiftSample/ViewController.swift b/Example/Auth/SwiftSample/ViewController.swift index d902b38..05b0dd2 100644 --- a/Example/Auth/SwiftSample/ViewController.swift +++ b/Example/Auth/SwiftSample/ViewController.swift @@ -232,9 +232,9 @@ final class ViewController: UIViewController, UITextFieldDelegate, AuthUIDelegat } case .createUser: Auth.auth().createUser(withEmail: emailField.text!, password: passwordField.text!) { - user, error in + result, error in self.ifNoError(error) { - self.showAlert(title: "Signed In With Credential", message: user?.textDescription) + self.showAlert(title: "Signed In With Credential", message: result?.user.textDescription) } } case .signOut: diff --git a/Example/Auth/Tests/FIRAuthTests.m b/Example/Auth/Tests/FIRAuthTests.m index d238057..34c0499 100644 --- a/Example/Auth/Tests/FIRAuthTests.m +++ b/Example/Auth/Tests/FIRAuthTests.m @@ -1592,9 +1592,9 @@ static const NSTimeInterval kWaitInterval = .5; [[FIRAuth auth] signOut:NULL]; [[FIRAuth auth] createUserWithEmail:kEmail password:kFakePassword - completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { + completion:^(FIRAuthDataResult *_Nullable result, NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); - [self assertUser:user]; + [self assertUser:result.user]; XCTAssertNil(error); [expectation fulfill]; }]; @@ -1614,9 +1614,10 @@ static const NSTimeInterval kWaitInterval = .5; [[FIRAuth auth] signOut:NULL]; [[FIRAuth auth] createUserWithEmail:kEmail password:kFakePassword - completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { + completion:^(FIRAuthDataResult *_Nullable result, + NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); - XCTAssertNil(user); + XCTAssertNil(result.user); XCTAssertEqual(error.code, FIRAuthErrorCodeWeakPassword); XCTAssertNotNil(error.userInfo[NSLocalizedDescriptionKey]); XCTAssertEqualObjects(error.userInfo[NSLocalizedFailureReasonErrorKey], reason); @@ -1700,7 +1701,8 @@ static const NSTimeInterval kWaitInterval = .5; [[FIRAuth auth] signOut:NULL]; [[FIRAuth auth] createUserWithEmail:kEmail password:@"" - completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { + completion:^(FIRAuthDataResult *_Nullable result, + NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertEqual(error.code, FIRAuthErrorCodeWeakPassword); [expectation fulfill]; @@ -1719,7 +1721,8 @@ static const NSTimeInterval kWaitInterval = .5; [[FIRAuth auth] signOut:NULL]; [[FIRAuth auth] createUserWithEmail:@"" password:kFakePassword - completion:^(FIRUser *_Nullable user, NSError *_Nullable error) { + completion:^(FIRAuthDataResult *_Nullable result, + NSError *_Nullable error) { XCTAssertTrue([NSThread isMainThread]); XCTAssertEqual(error.code, FIRAuthErrorCodeMissingEmail); [expectation fulfill]; |