adium 5914:c4923ddd82bf: Prompt the user to authenticate again w...

commits at adium.im commits at adium.im
Wed Apr 1 19:09:24 UTC 2015


details:	http://hg.adium.im/adium/rev/c4923ddd82bf
revision:	5914:c4923ddd82bf
branch:		GoogleOAuth2
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Wed Apr 01 21:07:40 2015 +0200

Prompt the user to authenticate again when using the refresh_token gives an error. Also, show the error to the user.

diffs (29 lines):

diff -r 1ff2b33ca0c1 -r c4923ddd82bf Plugins/Purple Service/AIPurpleGTalkAccount.m
--- a/Plugins/Purple Service/AIPurpleGTalkAccount.m	Wed Apr 01 20:30:40 2015 +0200
+++ b/Plugins/Purple Service/AIPurpleGTalkAccount.m	Wed Apr 01 21:07:40 2015 +0200
@@ -221,6 +221,17 @@
 	
 	AILogWithSignature(@"%@", responseDict);
 	
+	if ([responseDict objectForKey:@"error"]) {
+		// Delete the refresh token, so we don't use it again.
+		[[AIKeychain defaultKeychain_error:NULL] deleteGenericPasswordForService:self.service.serviceID
+																		 account:self.UID
+																		   error:NULL];
+		
+		[self setLastDisconnectionError:[NSString stringWithFormat:AILocalizedString(@"Retrieving OAuth token failed: %@", nil), [responseDict objectForKey:@"error_description"]]];
+		[self serverReportedInvalidPassword];
+		return;
+	}
+	
 	if (!self.UID.length) {
 		NSString *jsonWebToken = [responseDict objectForKey:@"id_token"];
 		
@@ -291,7 +302,6 @@
 
 -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
 	[self setLastDisconnectionError:[NSString stringWithFormat:AILocalizedString(@"OAuth authentication failed: %@", nil), error.description]];
-	[self setValue:[NSNumber numberWithBool:YES] forProperty:@"isDisconnecting" notify:NotifyNow];
 }
 
 - (void)retrievePasswordThenConnect




More information about the commits mailing list