mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-07 08:01:10 +00:00
only reauthenticate if validation failed
This commit is contained in:
parent
1938e480cc
commit
30b93a0468
@ -576,6 +576,13 @@ static NSString* const kBITAuthenticatorDidSkipOptionalLogin = @"BITAuthenticato
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)applicationWillResignActive:(NSNotification *)note {
|
||||||
|
if(BITAuthenticatorValidationTypeOnAppActive == self.validationType) {
|
||||||
|
self.installationIdentificationValidated = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
- (tValidationCompletion) defaultValidationCompletionBlock {
|
- (tValidationCompletion) defaultValidationCompletionBlock {
|
||||||
return ^(BOOL validated, NSError *error) {
|
return ^(BOOL validated, NSError *error) {
|
||||||
switch (self.validationType) {
|
switch (self.validationType) {
|
||||||
@ -584,15 +591,11 @@ static NSString* const kBITAuthenticatorDidSkipOptionalLogin = @"BITAuthenticato
|
|||||||
break;
|
break;
|
||||||
case BITAuthenticatorValidationTypeOnAppActive:
|
case BITAuthenticatorValidationTypeOnAppActive:
|
||||||
case BITAuthenticatorValidationTypeOnFirstLaunch:
|
case BITAuthenticatorValidationTypeOnFirstLaunch:
|
||||||
[self authenticateWithCompletion:nil];
|
if(!validated) {
|
||||||
|
[self authenticateWithCompletion:nil];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
- (void)applicationWillResignActive:(NSNotification *)note {
|
|
||||||
if(BITAuthenticatorValidationTypeOnAppActive == self.validationType) {
|
|
||||||
self.installationIdentificationValidated = NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -335,6 +335,26 @@ static void *kInstallationIdentification = &kInstallationIdentification;
|
|||||||
assertThat(error, notNilValue());
|
assertThat(error, notNilValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) testThatFailedRequiredValidationShowsAuthenticationViewController {
|
||||||
|
id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate));
|
||||||
|
_sut.delegate = delegateMock;
|
||||||
|
_sut.validationType = BITAuthenticatorValidationTypeOnAppActive;
|
||||||
|
|
||||||
|
[_sut validationFailedWithError:[NSError errorWithDomain:kBITAuthenticatorErrorDomain code:0 userInfo:nil]
|
||||||
|
completion:nil];
|
||||||
|
[verifyCount(delegateMock, times(1)) authenticator:_sut willShowAuthenticationController:(id)anything()];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) testThatFailedOptionalValidationDoesNotShowAuthenticationViewController {
|
||||||
|
id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate));
|
||||||
|
_sut.delegate = delegateMock;
|
||||||
|
_sut.validationType = BITAuthenticatorValidationTypeOptional;
|
||||||
|
|
||||||
|
[_sut validationFailedWithError:nil
|
||||||
|
completion:nil];
|
||||||
|
[verifyCount(delegateMock, never()) authenticator:_sut willShowAuthenticationController:(id)anything()];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) testThatSuccessValidationCallsTheCompletionBlock {
|
- (void) testThatSuccessValidationCallsTheCompletionBlock {
|
||||||
id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate));
|
id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate));
|
||||||
_sut.delegate = delegateMock;
|
_sut.delegate = delegateMock;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user