From 5bb6e0f091b76ed8a02ce402d766cf4e26d33784 Mon Sep 17 00:00:00 2001 From: Zsika Phillip Date: Wed, 25 Apr 2018 21:50:19 -0700 Subject: Adds new callback to createUse API (breaking change) (#1186) --- Example/Auth/Sample/MainViewController.m | 8 +++++--- Example/Auth/SwiftSample/ViewController.swift | 4 ++-- Example/Auth/Tests/FIRAuthTests.m | 15 +++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'Example') 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 *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 *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 *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]; -- cgit v1.2.3