Skip to content

Commit

Permalink
When the login info is wrong, show the login box again. This is just …
Browse files Browse the repository at this point in the history
…a temporary measure until a more permanent login screen can be established and does not have such niceties as pre-filling the username.
  • Loading branch information
ElDragonRojo committed Aug 7, 2013
1 parent 6a8c5de commit 6d1f152
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions Lemacs/GitHub/GHStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,30 @@
#import <UAGithubEngine/UAGithubEngine.h>
#import <UICKeyChainStore/UICKeyChainStore.h>

@interface GHStore ()

@property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;

@property (nonatomic, strong, readonly) NSURL *applicationDocumentsDirectory;
@property (nonatomic, strong, readonly) NSString *repositoryPath;

- (IBAction)removeContext;
- (IBAction)showLogin;

@end


void (^handleError)(NSError *) = ^(NSError *error){
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

if ([error.domain isEqualToString:@"HTTP"]) {
switch (error.code) {
case 403: // Happens when your password is wrong
error = [NSError errorWithDomain:error.domain code:error.code userInfo:@{NSLocalizedDescriptionKey : NSLocalizedString(@"GitHub refuses to speak to you. Check your login credentials.", @"Incorrect password description")}];
[[GHStore sharedStore] showLogin];
return;

case 405: // FIXME: Happens when trying to save when GitHub is down. Changes should be saved locally and synced next time.
case 502:
case 503:
Expand All @@ -41,19 +60,6 @@
};


@interface GHStore ()

@property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;

@property (nonatomic, strong, readonly) NSURL *applicationDocumentsDirectory;
@property (nonatomic, strong, readonly) NSString *repositoryPath;

- (IBAction)removeContext;

@end


@implementation GHStore

#pragma mark - UIAlertViewDelegate
Expand Down

0 comments on commit 6d1f152

Please sign in to comment.