Show an alert if the authentication token could not be stored into the keychain

If this occurs, the user has to authenticate every time the app starts or even when the app comes into foreground, depending on the `restrictionEnforcementFrequency` setting
This commit is contained in:
Andreas Linde
2014-01-10 19:47:50 +01:00
parent d5a6553357
commit dde368a952
15 changed files with 71 additions and 8 deletions

View File

@@ -153,6 +153,17 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
}
return NO;
}
- (void)alertOnFailureStoringTokenInKeychain {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
message:BITHockeyLocalizedString(@"HockeyAuthenticationViewControllerStorageError")
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
otherButtonTitles:nil];
[alertView setTag:1];
[alertView show];
}
- (void) identifyWithCompletion:(void (^)(BOOL identified, NSError *))completion {
if(_authenticationController) {
BITHockeyLog(@"Authentication controller already visible. Ingoring identify request");
@@ -245,6 +256,7 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
otherButtonTitles:nil];
[alertView setTag:0];
[alertView show];
}
}];
@@ -397,7 +409,10 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
[strongSelf storeInstallationIdentifier:authToken withType:strongSelf.identificationType];
[strongSelf dismissAuthenticationControllerAnimated:YES completion:nil];
strongSelf->_authenticationController = nil;
[self addStringValueToKeychain:email forKey:kBITAuthenticatorUserEmailKey];
BOOL success = [self addStringValueToKeychain:email forKey:kBITAuthenticatorUserEmailKey];
if (!success) {
[strongSelf alertOnFailureStoringTokenInKeychain];
}
} else {
identified = NO;
}
@@ -572,7 +587,10 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
NSString *email = nil;
[self.class email:&email andIUID:&installationIdentifier fromOpenURL:url];
if(email) {
[self addStringValueToKeychain:email forKey:kBITAuthenticatorUserEmailKey];
BOOL success = [self addStringValueToKeychain:email forKey:kBITAuthenticatorUserEmailKey];
if (!success) {
[self alertOnFailureStoringTokenInKeychain];
}
} else {
BITHockeyLog(@"No email found in URL: %@", url);
}
@@ -767,13 +785,15 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
[self removeKeyFromKeychain:kBITAuthenticatorIdentifierKey];
[self removeKeyFromKeychain:kBITAuthenticatorIdentifierTypeKey];
} else {
BOOL success = [self addStringValueToKeychainForThisDeviceOnly:installationIdentifier
BOOL success1 = [self addStringValueToKeychainForThisDeviceOnly:installationIdentifier
forKey:kBITAuthenticatorIdentifierKey];
NSParameterAssert(success);
success = [self addStringValueToKeychainForThisDeviceOnly:[self.class stringForIdentificationType:type]
NSParameterAssert(success1);
BOOL success2 = [self addStringValueToKeychainForThisDeviceOnly:[self.class stringForIdentificationType:type]
forKey:kBITAuthenticatorIdentifierTypeKey];
NSParameterAssert(success);
#pragma unused(success)
NSParameterAssert(success2);
if (!success1 || !success2) {
[self alertOnFailureStoringTokenInKeychain];
}
}
}
@@ -851,6 +871,8 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
[self validate];
if (alertView.tag == 0) {
[self validate];
}
}
@end

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Die Autorisierung ist fehlgeschlagen, da Ihr Gerät anscheinend nicht mit dem Internet verbunden ist. Bitte erneut versuchen.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Autorisierung fehlgeschlagen. Bitte erneut versuchen oder an den Entwickler dieser App wenden.";
"HockeyAuthenticationNotMember" = "Sie sind nicht berechtigt, diese App zu nutzen. Bitte wenden Sie sich an den Entwickler dieser App.";

View File

@@ -257,6 +257,8 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Failed to authorize because your device appears to be disconnected from the Internet. Please try again.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Failed to authorize. Please try again or contact the developer of this app.";
"HockeyAuthenticationNotMember" = "You are not authorized to use this app. Please contact the developer of this app.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "No se ha podido realizar la autorización porque su dispositivo parece no estar conectado a Internet. Vuelva a intentarlo.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Error de autorización. Vuelva a intentarlo o póngase en contacto con el desarrollador de la app.";
"HockeyAuthenticationNotMember" = "No tiene autorización para usar esta app. Póngase en contacto con el desarrollador de la app.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Échec de l'autorisation. Votre appareil semble déconnecté d'Internet. Réessayez.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Échec de l'autorisation. Réessayez ou contactez le développeur de l'application.";
"HockeyAuthenticationNotMember" = "Vous n'êtes pas autorisé à utiliser cette application. Contactez le développeur de l'application.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Autorizacija nije uspjela. Vaš uređaj nema pristup internetu. Molimo Vas pokušajte iznova.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Autorizacija nije uspjela. Molimo Vas pokušajte iznova ili kontaktirajte razvojnog programera ove aplikacije.";
"HockeyAuthenticationNotMember" = "Vi niste autorizirani za korištenje ove aplikacije. Molimo Vas kontaktirajte razvojnog programera ove aplikacije.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "A hitelesítés sikertelen, mert készüléke nem csatlakozik az internethez. Kérjük, próbálja meg később újra.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "A hitelesítés sikertelen. Kérjük, próbálja meg később újra vagy lépjen kapcsolatba az alkalmazás fejlesztőjével.";
"HockeyAuthenticationNotMember" = "Nem jogosult az alkalmazás használatára. Kérjük, lépjen kapcsolatba az alkalmazás fejlesztőjével.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Autorizzazione non riuscita. Pare che il dispositivo non sia connesso a Internet. Riprova.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Autorizzazione non riuscita. Riprova o contatta lo sviluppatore di questa app.";
"HockeyAuthenticationNotMember" = "Non sei autorizzato a usare questa app. Contatta lo sviluppatore di questa app.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "デバイスがインターネットに接続されていないため、認証できません。やり直してください。";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "認証できませんでした。やり直すか、このAppのデベロッパに連絡してください。";
"HockeyAuthenticationNotMember" = "このAppの使用を認証されていません。このAppのデベロッパに連絡してください。";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Identiteitscontrole mislukt omdat uw apparaat niet is verbonden met het internet. Probeer opnieuw.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Identiteitscontrole mislukt. Probeer opnieuw of neem contact op met de ontwikkelaar van deze app.";
"HockeyAuthenticationNotMember" = "U bent niet gemachtigd om deze app te gebruiken. Neem contact op met de ontwikkelaar van deze app.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Falha ao autorizar porque provavelmente o dispositivo não tem ligação à Internet. Tente novamente.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Falha ao autorizar. Tente novamente ou contacte o programador desta aplicação.";
"HockeyAuthenticationNotMember" = "Não está autorizado a utilizar esta aplicação. Contacte o programador desta aplicação.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Não foi possível autorizar porque seu dispositivo parece estar desconectado da Internet. Tente novamente.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Falha ao autorizar. Tente novamente ou contate o desenvolvedor deste aplicativo.";
"HockeyAuthenticationNotMember" = "Você não tem autorização para usar este aplicativo. Contate o desenvolvedor deste aplicativo.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Failed to authorize because your device appears to be disconnected from the Internet. Please try again.";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Failed to authorize. Please try again or contact the developer of this app.";
"HockeyAuthenticationNotMember" = "You are not authorized to use this app. Please contact the developer of this app.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "Не удалось авторизоваться, так как ваше устройство не подключено к интернету. Попробуйте еще раз ";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "Авторизация не удалась. Попробуйте еще раз или свяжитесь с разработчиком приложения.";
"HockeyAuthenticationNotMember" = "У вас нет разрешения использовать это приложение. Обратитесь к разработчику приложения.";

View File

@@ -257,6 +257,9 @@
/* Error presented to the user if authentication failed because of networking issues */
"HockeyAuthenticationViewControllerNetworkError" = "你设备的 Internet 连接似乎已断开,导致授权失败。请再试一次。";
/* Error presented to the user if authentication could not be stored on the device */
"HockeyAuthenticationViewControllerStorageError" = "Your authentication token could not be stored due to a keychain error. Please contact the developer of the app.";
"HockeyAuthenticationFailedAuthenticate" = "授权错误。请再试一次或联系这个 app 的开发人员。";
"HockeyAuthenticationNotMember" = "你未获授权使用这个程序。请联系这个 app 的开发人员。";