Skip to content

Commit 65c5ca3

Browse files
committed
Merge branch 'v0.6.2' of github.com:firebase/FirebaseUI-iOS into v0.6.2
2 parents 8b9c58b + 4833b60 commit 65c5ca3

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

FirebaseAuthUI/FIRAuthUI.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,20 @@ typedef void (^FIRAuthUIResultCallback)(FIRUser *_Nullable user, NSError *_Nulla
132132
*/
133133
- (UIViewController *)authViewController;
134134

135+
136+
/** @fn signOut:
137+
@brief Signs out the current user from Firbase and all providers.
138+
@param error Optionally; if an error occurs during Firebase signout, upon return contains an
139+
NSError object that describes the problem; is nil otherwise. If Firebase error occurs all providers
140+
are not logged-out and sign-out should be retried.
141+
@return @YES when the sign out request was successful. @NO otherwise.
142+
@remarks Possible error codes:
143+
- @c FIRAuthErrorCodeKeychainError Indicates an error occurred when accessing the keychain.
144+
The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary
145+
will contain more information about the error encountered.
146+
*/
147+
- (BOOL)signOut:(NSError *_Nullable *_Nullable)error;
148+
135149
@end
136150

137151
NS_ASSUME_NONNULL_END

FirebaseAuthUI/FIRAuthUI.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ - (UIViewController *)authViewController {
101101
return [[UINavigationController alloc] initWithRootViewController:controller];
102102
}
103103

104+
- (BOOL)signOut:(NSError *_Nullable *_Nullable)error {
105+
// sign out from Firebase
106+
BOOL success = [self.auth signOut:error];
107+
if (!error && success) {
108+
// sign out from all providers (wipes provider tokens too)
109+
for (id<FIRAuthProviderUI> provider in _providers) {
110+
[provider signOut];
111+
}
112+
}
113+
114+
return success;
115+
}
116+
104117
#pragma mark - Internal Methods
105118

106119
- (void)invokeResultCallbackWithUser:(FIRUser *_Nullable)user error:(NSError *_Nullable)error {

samples/objc/FirebaseUI-demo-objc/Samples/Auth/FIRAuthViewController.m

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,11 @@ - (NSString *)getAllIdTokens {
174174
}
175175

176176
- (void)signOut {
177-
// sign out from Firebase
178177
NSError *error;
179-
[self.auth signOut:&error];
178+
[self.authUI signOut:&error];
180179
if (error) {
181180
[self showAlert:error.localizedDescription];
182181
}
183-
184-
// sign out from all providers (wipes provider tokens too)
185-
for (id<FIRAuthProviderUI> provider in _authUI.providers) {
186-
[provider signOut];
187-
}
188-
189182
}
190183

191184
- (void)showAlert:(NSString *)message {

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FIRAuthViewController.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,14 @@ class FIRAuthViewController: UITableViewController {
8080
@IBAction func onAuthorize(_ sender: AnyObject) {
8181
if (self.auth?.currentUser) != nil {
8282
do {
83-
try self.auth?.signOut()
83+
try self.authUI?.signOut()
8484
} catch let error {
8585
// Again, fatalError is not a graceful way to handle errors.
8686
// This error is most likely a network error, so retrying here
8787
// makes sense.
8888
fatalError("Could not sign out: \(error)")
8989
}
9090

91-
for provider in self.authUI!.providers {
92-
provider.signOut()
93-
}
94-
9591
} else {
9692
let controller = self.authUI!.authViewController()
9793
self.present(controller, animated: true, completion: nil)

0 commit comments

Comments
 (0)