@@ -32,7 +32,7 @@ @implementation PFUserAuthenticationController
3232#pragma mark - Init
3333// /--------------------------------------
3434
35- - (instancetype )initWithDataSource : (id <PFCurrentUserControllerProvider>)dataSource {
35+ - (instancetype )initWithDataSource : (id <PFCurrentUserControllerProvider, PFUserControllerProvider >)dataSource {
3636 self = [super init ];
3737 if (!self) return nil ;
3838
@@ -43,7 +43,7 @@ - (instancetype)initWithDataSource:(id<PFCurrentUserControllerProvider>)dataSour
4343 return self;
4444}
4545
46- + (instancetype )controllerWithDataSource : (id <PFCurrentUserControllerProvider>)dataSource {
46+ + (instancetype )controllerWithDataSource : (id <PFCurrentUserControllerProvider, PFUserControllerProvider >)dataSource {
4747 return [[self alloc ] initWithDataSource: dataSource];
4848}
4949
@@ -94,7 +94,7 @@ - (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType {
9494#pragma mark - Authentication
9595// /--------------------------------------
9696
97- - (BFTask PF_GENERIC (NSNumber *)*)restoreAuthenticationAsyncWithAuthData:(nullable NSDictionary *)authData
97+ - (BFTask PF_GENERIC (NSNumber *)*)restoreAuthenticationAsyncWithAuthData:(nullable NSDictionary PF_GENERIC ( NSString *, NSString *) *)authData
9898 forAuthType:(NSString *)authType {
9999 id <PFUserAuthenticationDelegate> provider = [self authenticationDelegateForAuthType: authType];
100100 if (!provider) {
@@ -113,12 +113,12 @@ - (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType {
113113#pragma mark - Log In
114114// /--------------------------------------
115115
116- - (BFTask *)logInUserAsyncWithAuthType : (NSString *)authType authData : (NSDictionary *)authData {
116+ - (BFTask PF_GENERIC (PFUser *)*)logInUserAsyncWithAuthType:(NSString *)authType
117+ authData:(NSDictionary PF_GENERIC (NSString *, NSString *)*)authData {
117118 // TODO: (nlutsenko) Make it fully async.
118- // TODO: (nlutsenko) Inject `PFUserController` here.
119119 PFUser *currentUser = [PFUser currentUser ];
120120 if (currentUser && [PFAnonymousUtils isLinkedWithUser: currentUser]) {
121- if ([ currentUser isLazy ] ) {
121+ if (currentUser. isLazy ) {
122122 PFUser *user = currentUser;
123123 BFTask *resolveLaziness = nil ;
124124 NSDictionary *oldAnonymousData = nil ;
@@ -135,7 +135,7 @@ - (BFTask *)logInUserAsyncWithAuthType:(NSString *)authType authData:(NSDictiona
135135 }
136136
137137 return [resolveLaziness continueAsyncWithBlock: ^id (BFTask *task) {
138- if (task.isCancelled || task.exception || task. error ) {
138+ if (task.cancelled || task.faulted ) {
139139 [user.authData removeObjectForKey: authType];
140140 [user.linkedServiceNames removeObject: authType];
141141 [user restoreAnonymity: oldAnonymousData];
@@ -144,28 +144,26 @@ - (BFTask *)logInUserAsyncWithAuthType:(NSString *)authType authData:(NSDictiona
144144 return task.result ;
145145 }];
146146 } else {
147- return [[currentUser linkWithAuthTypeInBackground: authType
148- authData: authData] continueAsyncWithBlock: ^id (BFTask *task) {
147+ return [[currentUser linkWithAuthTypeInBackground: authType authData: authData] continueAsyncWithBlock: ^id (BFTask *task) {
149148 NSError *error = task.error ;
150149 if (error) {
151150 if (error.code == kPFErrorAccountAlreadyLinked ) {
152151 // An account that's linked to the given authData already exists,
153152 // so log in instead of trying to claim.
154- return [[PFUser userController ] logInCurrentUserAsyncWithAuthType: authType
155- authData: authData
156- revocableSession: [PFUser _isRevocableSessionEnabled ]];
153+ return [self .dataSource. userController logInCurrentUserAsyncWithAuthType: authType
154+ authData: authData
155+ revocableSession: [PFUser _isRevocableSessionEnabled ]];
157156 } else {
158157 return task;
159158 }
160159 }
161-
162160 return currentUser;
163161 }];
164162 }
165163 }
166- return [[PFUser userController ] logInCurrentUserAsyncWithAuthType: authType
167- authData: authData
168- revocableSession: [PFUser _isRevocableSessionEnabled ]];
164+ return [self .dataSource. userController logInCurrentUserAsyncWithAuthType: authType
165+ authData: authData
166+ revocableSession: [PFUser _isRevocableSessionEnabled ]];
169167}
170168
171169@end
0 commit comments