Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
gglocker/gglocker/LoginCheck.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
43 lines (39 sloc)
1.87 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // LoginCheck.m | |
| // gglocker | |
| // | |
| // Created by gabry on 9/11/12. | |
| // Copyright (c) 2012 Gabriele Greco. All rights reserved. | |
| // | |
| #import "LoginCheck.h" | |
| #import "LoginViewController.h" | |
| #import "nsextensions.h" | |
| #import "BaseController.h" | |
| @implementation LoginCheck | |
| -(void)perform{ | |
| LoginViewController *src = (LoginViewController *)[self sourceViewController]; | |
| BaseController *dst = (BaseController *)[self destinationViewController]; | |
| NSLog(@"Dest: %@", dst); | |
| if (src.disk_md5_pwd) { | |
| if ([src.disk_md5_pwd isEqualToString:[src.pwd.text md5]]) { | |
| dst.pwd = src.pwd.text; | |
| src.view.window.rootViewController = dst; | |
| } else { | |
| UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"WARNING" message:@"Wrong password!" preferredStyle:UIAlertControllerStyleAlert]; | |
| [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil]]; | |
| [src presentViewController:alert animated:YES completion:nil]; | |
| } | |
| } else { | |
| if ([src.pwd.text isEqualToString:src.retype_field.text]) { | |
| NSString *dir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; | |
| [[src.pwd.text md5] writeToFile:[dir stringByAppendingPathComponent:@"/identity"] atomically:NO encoding:NSUTF8StringEncoding error:nil]; | |
| src.view.window.rootViewController = dst; | |
| dst.pwd = src.pwd.text; | |
| } else { | |
| UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"WARNING" message:@"Both field should contain the same password!" preferredStyle:UIAlertControllerStyleAlert]; | |
| [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil]]; | |
| [src presentViewController:alert animated:YES completion:nil]; | |
| } | |
| } | |
| } | |
| @end |