mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-01 16:06:59 +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 {
|
||||
return ^(BOOL validated, NSError *error) {
|
||||
switch (self.validationType) {
|
||||
@ -584,15 +591,11 @@ static NSString* const kBITAuthenticatorDidSkipOptionalLogin = @"BITAuthenticato
|
||||
break;
|
||||
case BITAuthenticatorValidationTypeOnAppActive:
|
||||
case BITAuthenticatorValidationTypeOnFirstLaunch:
|
||||
[self authenticateWithCompletion:nil];
|
||||
if(!validated) {
|
||||
[self authenticateWithCompletion:nil];
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
||||
- (void)applicationWillResignActive:(NSNotification *)note {
|
||||
if(BITAuthenticatorValidationTypeOnAppActive == self.validationType) {
|
||||
self.installationIdentificationValidated = NO;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -335,6 +335,26 @@ static void *kInstallationIdentification = &kInstallationIdentification;
|
||||
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 {
|
||||
id delegateMock = mockProtocol(@protocol(BITAuthenticatorDelegate));
|
||||
_sut.delegate = delegateMock;
|
||||
|
Loading…
x
Reference in New Issue
Block a user