Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions FirebaseAuthUI/FIRAuthPickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,22 @@ - (void)signInWithProviderUI:(id<FIRAuthProviderUI>)providerUI {
// Sign out first to make sure sign in starts with a clean state.
[providerUI signOut];
[providerUI signInWithEmail:nil
presentingViewController:self
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
if (error) {
[self decrementActivity];

if (error.code == FIRAuthUIErrorCodeUserCancelledSignIn) {
// User cancelled sign in, Do nothing.
return;
}

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:nil error:error];
}];
return;
}
presentingViewController:self
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
if (error) {
[self decrementActivity];

if (error.code == FIRAuthUIErrorCodeUserCancelledSignIn) {
// User cancelled sign in, Do nothing.
return;
}

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:nil error:error];
}];
return;
}

[self.auth signInWithCredential:credential
completion:^(FIRUser *_Nullable user, NSError *_Nullable error) {
Expand Down Expand Up @@ -231,22 +231,22 @@ - (void)handleAccountLinkingForEmail:(NSString *)email
// Sign out first to make sure sign in starts with a clean state.
[bestProvider signOut];
[bestProvider signInWithEmail:email
presentingViewController:self
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
if (error) {
[self decrementActivity];

if (error.code == FIRAuthUIErrorCodeUserCancelledSignIn) {
// User cancelled sign in, Do nothing.
return;
}

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:nil error:error];
}];
return;
}
presentingViewController:self
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
if (error) {
[self decrementActivity];

if (error.code == FIRAuthUIErrorCodeUserCancelledSignIn) {
// User cancelled sign in, Do nothing.
return;
}

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:nil error:error];
}];
return;
}

[self.auth signInWithCredential:credential completion:^(FIRUser *_Nullable user,
NSError *_Nullable error) {
Expand Down
42 changes: 21 additions & 21 deletions FirebaseAuthUI/FIREmailEntryViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,27 +207,27 @@ - (void)signInWithProvider:(id<FIRAuthProviderUI>)provider email:(NSString *)ema
// Sign out first to make sure sign in starts with a clean state.
[provider signOut];
[provider signInWithEmail:email
presentingViewController:self
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
if (error) {
[self decrementActivity];

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:nil error:error];
}];
return;
}

[self.auth signInWithCredential:credential
completion:^(FIRUser *_Nullable user, NSError *_Nullable error) {
[self decrementActivity];

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:user error:error];
}];
}];
}];
presentingViewController:self
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
if (error) {
[self decrementActivity];

[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:nil error:error];
}];
return;
}

[self.auth signInWithCredential:credential
completion:^(FIRUser *_Nullable user, NSError *_Nullable error) {
[self decrementActivity];
[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self.authUI invokeResultCallbackWithUser:user error:error];
}];
}];
}];
}

@end
80 changes: 41 additions & 39 deletions FirebaseFacebookAuthUITests/FirebaseFacebookAuthUITests.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ - (void)testSuccessfullLogin {

XCTestExpectation *expectation = [self expectationWithDescription:@"logged in"];
[self.provider signInWithEmail:nil
presentingViewController:nil
completion:^(FIRAuthCredential * _Nullable credential, NSError * _Nullable error) {
XCTAssertNil(error);
XCTAssertNotNil(credential);
FIRAuthCredential *expectedCredential = [FIRFacebookAuthProvider credentialWithAccessToken:testToken];
XCTAssertEqualObjects(credential.provider, expectedCredential.provider);
XCTAssertNil(self.provider.idToken);

//verify that we are using token from server
OCMVerify([mockToken tokenString]);

[expectation fulfill];
}];
presentingViewController:nil
completion:^(FIRAuthCredential * _Nullable credential, NSError * _Nullable error) {
XCTAssertNil(error);
XCTAssertNotNil(credential);
FIRAuthCredential *expectedCredential = [FIRFacebookAuthProvider credentialWithAccessToken:testToken];
XCTAssertEqualObjects(credential.provider, expectedCredential.provider);
XCTAssertNil(self.provider.idToken);

//verify that we are using token from server
OCMVerify([mockToken tokenString]);

[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:0.1 handler:^(NSError * _Nullable error) {
XCTAssertNil(error);
}];
Expand All @@ -107,19 +107,19 @@ - (void)testCancelLogin {

XCTestExpectation *expectation = [self expectationWithDescription:@"logged in"];
[self.provider signInWithEmail:nil
presentingViewController:nil
completion:^(FIRAuthCredential * _Nullable credential,
NSError * _Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqual(error.code, FIRAuthUIErrorCodeUserCancelledSignIn);
XCTAssertNil(credential);
XCTAssertNil(self.provider.idToken);

//verify that we are not using token from server if user canceled request
OCMReject([mockToken tokenString]);

[expectation fulfill];
}];
presentingViewController:nil
completion:^(FIRAuthCredential * _Nullable credential,
NSError * _Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqual(error.code, FIRAuthUIErrorCodeUserCancelledSignIn);
XCTAssertNil(credential);
XCTAssertNil(self.provider.idToken);

//verify that we are not using token from server if user canceled request
OCMReject([mockToken tokenString]);

[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:0.1 handler:^(NSError * _Nullable error) {
XCTAssertNil(error);
}];
Expand All @@ -132,15 +132,15 @@ - (void)testErrorLogin {

XCTestExpectation *expectation = [self expectationWithDescription:@"logged in"];
[self.provider signInWithEmail:nil
presentingViewController:nil
completion:^(FIRAuthCredential * _Nullable credential,
NSError * _Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqual(error.userInfo[NSUnderlyingErrorKey], testError);
XCTAssertNil(credential);
XCTAssertNil(self.provider.idToken);
[expectation fulfill];
}];
presentingViewController:nil
completion:^(FIRAuthCredential * _Nullable credential,
NSError * _Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqual(error.userInfo[NSUnderlyingErrorKey], testError);
XCTAssertNil(credential);
XCTAssertNil(self.provider.idToken);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:0.1 handler:^(NSError * _Nullable error) {
XCTAssertNil(error);
}];
Expand All @@ -150,19 +150,21 @@ - (void)testSignOut {

// used to make possible initialization of FIRFacebookAuthUI
id mockProviderClass = OCMClassMock([FIRFacebookAuthUI class]);
OCMStub(ClassMethod([mockProviderClass frameworkBundle])).andReturn([NSBundle bundleForClass:[self class]]);
OCMExpect(ClassMethod([mockProviderClass frameworkBundle])).andReturn([NSBundle bundleForClass:[self class]]);

id mockProvider = OCMPartialMock([[FIRFacebookAuthUI alloc] init]);
id mockFacebookManager = OCMClassMock([FBSDKLoginManager class]);

// stub login manager
OCMStub(ClassMethod([mockProvider frameworkBundle])).andReturn([NSBundle bundleForClass:[self class]]);
OCMStub([mockProvider createLoginManger]).andReturn(mockFacebookManager);
OCMExpect(ClassMethod([mockProvider frameworkBundle])).andReturn([NSBundle bundleForClass:[self class]]);
OCMExpect([mockProvider createLoginManger]).andReturn(mockFacebookManager);
[mockProvider configureProvider];

OCMExpect([mockFacebookManager logOut]);
[mockProvider signOut];

OCMVerify([mockFacebookManager logOut]);
OCMVerifyAll(mockFacebookManager);
OCMVerifyAll(mockProvider);

}

Expand Down
Loading