CCLogin.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. //
  2. // CCLogin.m
  3. // Nextcloud iOS
  4. //
  5. // Created by Marino Faggiana on 09/04/15.
  6. // Copyright (c) 2017 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "CCLogin.h"
  24. #import "AppDelegate.h"
  25. #import "CCUtility.h"
  26. #import "NCBridgeSwift.h"
  27. #import "NCNetworkingSync.h"
  28. @interface CCLogin ()
  29. {
  30. AppDelegate *appDelegate;
  31. UIView *rootView;
  32. }
  33. @end
  34. @implementation CCLogin
  35. - (void)viewDidLoad
  36. {
  37. [super viewDidLoad];
  38. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  39. self.imageBrand.image = [UIImage imageNamed:@"loginLogo"];
  40. self.login.backgroundColor = [NCBrandColor sharedInstance].customer;
  41. // Bottom label
  42. self.bottomLabel.text = NSLocalizedString([NCBrandOptions sharedInstance].textLoginProvider, nil);
  43. self.bottomLabel.userInteractionEnabled = YES;
  44. if ([NCBrandOptions sharedInstance].disable_linkLoginProvider) {
  45. self.bottomLabel.hidden = YES;
  46. }
  47. if (self.view.frame.size.width == ([[UIScreen mainScreen] bounds].size.width*([[UIScreen mainScreen] bounds].size.width<[[UIScreen mainScreen] bounds].size.height))+([[UIScreen mainScreen] bounds].size.height*([[UIScreen mainScreen] bounds].size.width>[[UIScreen mainScreen] bounds].size.height))) {
  48. // Portrait
  49. if ([NCBrandOptions sharedInstance].disable_linkLoginProvider == NO)
  50. self.bottomLabel.hidden = NO;
  51. self.loginTypeView.hidden = NO;
  52. } else {
  53. // Landscape
  54. self.bottomLabel.hidden = YES;
  55. self.loginTypeView.hidden = YES;
  56. }
  57. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tabBottomLabel)];
  58. [self.bottomLabel addGestureRecognizer:tapGesture];
  59. self.annulla.tintColor = [NCBrandColor sharedInstance].customer;
  60. [self.baseUrl setDelegate:self];
  61. [self.password setDelegate:self];
  62. [self.user setDelegate:self];
  63. [self.baseUrl setFont:[UIFont systemFontOfSize:13]];
  64. [self.user setFont:[UIFont systemFontOfSize:13]];
  65. [self.password setFont:[UIFont systemFontOfSize:13]];
  66. self.imageBaseUrl.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginURL"] color:[NCBrandColor sharedInstance].customer];
  67. self.imageUser.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginUser"] color:[NCBrandColor sharedInstance].customer];
  68. self.imagePassword.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginPassword"] color:[NCBrandColor sharedInstance].customer];
  69. self.loadingBaseUrl.image = [UIImage animatedImageWithAnimatedGIFURL:[[NSBundle mainBundle] URLForResource: @"loading@2x" withExtension:@"gif"]];
  70. self.loadingBaseUrl.hidden = YES;
  71. // Brand
  72. if ([NCBrandOptions sharedInstance].disable_request_login_url) {
  73. _baseUrl.text = [NCBrandOptions sharedInstance].loginBaseUrl;
  74. _imageBaseUrl.hidden = YES;
  75. _baseUrl.hidden = YES;
  76. }
  77. if (_loginType == loginAdd) {
  78. // Login Flow ?
  79. if ([NCBrandOptions sharedInstance].use_login_web_flow) {
  80. _imageUser.hidden = YES;
  81. _user.hidden = YES;
  82. _imagePassword.hidden = YES;
  83. _password.hidden = YES;
  84. }
  85. }
  86. if (_loginType == loginAddForced) {
  87. _annulla.hidden = YES;
  88. // Login Flow ?
  89. if ([NCBrandOptions sharedInstance].use_login_web_flow) {
  90. _imageUser.hidden = YES;
  91. _user.hidden = YES;
  92. _imagePassword.hidden = YES;
  93. _password.hidden = YES;
  94. }
  95. }
  96. if (_loginType == loginModifyPasswordUser) {
  97. _baseUrl.text = appDelegate.activeUrl;
  98. _baseUrl.userInteractionEnabled = NO;
  99. _baseUrl.textColor = [UIColor lightGrayColor];
  100. _user.text = appDelegate.activeUser;
  101. _user.userInteractionEnabled = NO;
  102. _user.textColor = [UIColor lightGrayColor];
  103. }
  104. self.baseUrl.placeholder = NSLocalizedString(@"_login_url_", nil);
  105. self.user.placeholder = NSLocalizedString(@"_username_", nil);
  106. self.password.placeholder = NSLocalizedString(@"_password_", nil);
  107. [self.annulla setTitle:NSLocalizedString(@"_cancel_", nil) forState:UIControlStateNormal];
  108. [self.login setTitle:NSLocalizedString(@"_login_", nil) forState:UIControlStateNormal];
  109. [self.loginTypeView setTitle:NSLocalizedString(@"_traditional_login_", nil) forState:UIControlStateNormal];
  110. [self.loginTypeView setTitleColor:[NCBrandColor sharedInstance].customer forState:UIControlStateNormal];
  111. }
  112. - (void)viewWillAppear:(BOOL)animated
  113. {
  114. [super viewWillAppear:animated];
  115. // verify URL
  116. if (_loginType == loginModifyPasswordUser && [self.baseUrl.text length] > 0)
  117. [self testUrl];
  118. }
  119. // E' apparsa
  120. - (void)viewDidAppear:(BOOL)animated
  121. {
  122. [super viewDidAppear:animated];
  123. }
  124. //
  125. - (void)viewDidDisappear:(BOOL)animated
  126. {
  127. [super viewDidDisappear:animated];
  128. if ([self.delegate respondsToSelector:@selector(loginDisappear)])
  129. [self.delegate loginDisappear];
  130. }
  131. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  132. {
  133. [textField resignFirstResponder];
  134. return YES;
  135. }
  136. - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
  137. {
  138. [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
  139. if (self.view.frame.size.width == ([[UIScreen mainScreen] bounds].size.width*([[UIScreen mainScreen] bounds].size.width<[[UIScreen mainScreen] bounds].size.height))+([[UIScreen mainScreen] bounds].size.height*([[UIScreen mainScreen] bounds].size.width>[[UIScreen mainScreen] bounds].size.height))) {
  140. // Portrait
  141. if ([NCBrandOptions sharedInstance].disable_linkLoginProvider == NO)
  142. self.bottomLabel.hidden = NO;
  143. self.loginTypeView.hidden = NO;
  144. } else {
  145. // Landscape
  146. self.bottomLabel.hidden = YES;
  147. self.loginTypeView.hidden = YES;
  148. }
  149. }];
  150. [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
  151. }
  152. #pragma --------------------------------------------------------------------------------------------
  153. #pragma mark == Chech Server URL ==
  154. #pragma --------------------------------------------------------------------------------------------
  155. - (void)testUrl
  156. {
  157. self.login.enabled = NO;
  158. self.loadingBaseUrl.hidden = NO;
  159. // Check whether baseUrl contain protocol. If not add https:// by default.
  160. if(![self.baseUrl.text hasPrefix:@"https"] && ![self.baseUrl.text hasPrefix:@"http"]) {
  161. self.baseUrl.text = [NSString stringWithFormat:@"https://%@",self.baseUrl.text];
  162. }
  163. // Remove stored cookies
  164. NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
  165. for (NSHTTPCookie *cookie in [storage cookies])
  166. {
  167. [storage deleteCookie:cookie];
  168. }
  169. // Test Login Flow
  170. if ([self.baseUrl.text length] > 0 && _user.hidden && _password.hidden) {
  171. NSString *urlBase = self.baseUrl.text;
  172. // Remove trailing slash
  173. if ([self.baseUrl.text hasSuffix:@"/"])
  174. urlBase = [self.baseUrl.text substringToIndex:[self.baseUrl.text length] - 1];
  175. // Add end point flow
  176. urlBase = [urlBase stringByAppendingString:flowEndpoint];
  177. NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlBase] cachePolicy:0 timeoutInterval:20.0];
  178. [request addValue:[CCUtility getUserAgent] forHTTPHeaderField:@"User-Agent"];
  179. [request addValue:@"true" forHTTPHeaderField:@"OCS-APIRequest"];
  180. NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  181. NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
  182. NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
  183. dispatch_async(dispatch_get_main_queue(), ^{
  184. self.login.enabled = YES;
  185. self.loadingBaseUrl.hidden = YES;
  186. if (error) {
  187. if ([error code] == NSURLErrorServerCertificateUntrusted) {
  188. [[CCCertificate sharedManager] presentViewControllerCertificateWithTitle:[error localizedDescription] viewController:self delegate:self];
  189. } else {
  190. _imageUser.hidden = NO;
  191. _user.hidden = NO;
  192. _imagePassword.hidden = NO;
  193. _password.hidden = NO;
  194. [self.loginTypeView setTitle:NSLocalizedString(@"_web_login_", nil) forState:UIControlStateNormal];
  195. }
  196. } else {
  197. [self dismissViewControllerAnimated:YES completion: ^{
  198. appDelegate.activeLoginWeb = [CCLoginWeb new];
  199. appDelegate.activeLoginWeb.loginType = _loginType;
  200. appDelegate.activeLoginWeb.delegate = (id<CCLoginDelegateWeb>)self.delegate;
  201. appDelegate.activeLoginWeb.urlBase = urlBase;
  202. [appDelegate.activeLoginWeb presentModalWithDefaultTheme:(UIViewController *)self.delegate];
  203. }];
  204. }
  205. });
  206. }];
  207. [task resume];
  208. } else {
  209. NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.baseUrl.text] cachePolicy:0 timeoutInterval:20.0];
  210. [request addValue:[CCUtility getUserAgent] forHTTPHeaderField:@"User-Agent"];
  211. NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  212. NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
  213. NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
  214. dispatch_async(dispatch_get_main_queue(), ^{
  215. self.login.enabled = YES;
  216. self.loadingBaseUrl.hidden = YES;
  217. if (error != nil) {
  218. // self signed certificate
  219. if ([error code] == NSURLErrorServerCertificateUntrusted) {
  220. [[CCCertificate sharedManager] presentViewControllerCertificateWithTitle:[error localizedDescription] viewController:self delegate:self];
  221. } else {
  222. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_connection_error_", nil) message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
  223. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  224. [alertController addAction:okAction];
  225. [self presentViewController:alertController animated:YES completion:nil];
  226. }
  227. }
  228. });
  229. }];
  230. [task resume];
  231. }
  232. }
  233. - (void)trustedCerticateAccepted
  234. {
  235. NSLog(@"[LOG] Certificate trusted");
  236. }
  237. - (void)trustedCerticateDenied
  238. {
  239. if (_loginType == loginModifyPasswordUser)
  240. [self handleAnnulla:self];
  241. }
  242. -(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
  243. {
  244. // The pinnning check
  245. if ([[CCCertificate sharedManager] checkTrustedChallenge:challenge]) {
  246. completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
  247. } else {
  248. completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
  249. }
  250. }
  251. #pragma --------------------------------------------------------------------------------------------
  252. #pragma mark == Login ==
  253. #pragma --------------------------------------------------------------------------------------------
  254. - (void)loginCloudUrl:(NSString *)url user:(NSString *)user password:(NSString *)password
  255. {
  256. NSError *error = [[NCNetworkingSync sharedManager] checkServer:[NSString stringWithFormat:@"%@%@", url, webDAV] user:user userID:user password:password];
  257. dispatch_async(dispatch_get_main_queue(), ^{
  258. self.login.enabled = NO;
  259. self.loadingBaseUrl.hidden = NO;
  260. if (!error) {
  261. // account
  262. NSString *account = [NSString stringWithFormat:@"%@ %@", user, url];
  263. if (_loginType == loginModifyPasswordUser) {
  264. // Change Password
  265. tableAccount *tbAccount = [[NCManageDatabase sharedInstance] setAccountPassword:account password:password];
  266. // Setting appDelegate active account
  267. [appDelegate settingActiveAccount:tbAccount.account activeUrl:tbAccount.url activeUser:tbAccount.user activeUserID:tbAccount.userID activePassword:tbAccount.password];
  268. // Dismiss
  269. if ([self.delegate respondsToSelector:@selector(loginSuccess:)])
  270. [self.delegate loginSuccess:_loginType];
  271. [self dismissViewControllerAnimated:YES completion:nil];
  272. } else {
  273. [[NCManageDatabase sharedInstance] deleteAccount:account];
  274. [[NCManageDatabase sharedInstance] addAccount:account url:url user:user password:password loginFlow:false];
  275. // Read User Profile
  276. CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:account];
  277. metadataNet.action = actionGetUserProfile;
  278. [appDelegate.netQueue addOperation:[[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:user withUserID:user withPassword:password withUrl:url]];
  279. }
  280. } else {
  281. if ([error code] != NSURLErrorServerCertificateUntrusted) {
  282. NSString *description = [error.userInfo objectForKey:@"NSLocalizedDescription"];
  283. NSString *message = [NSString stringWithFormat:@"%@.\n%@", NSLocalizedStringFromTable(@"_not_possible_connect_to_server_", @"Error", nil), description];
  284. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  285. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  286. [alertController addAction:okAction];
  287. [self presentViewController:alertController animated:YES completion:nil];
  288. }
  289. }
  290. self.login.enabled = YES;
  291. self.loadingBaseUrl.hidden = YES;
  292. });
  293. }
  294. #pragma --------------------------------------------------------------------------------------------
  295. #pragma mark ==== User Profile ====
  296. #pragma --------------------------------------------------------------------------------------------
  297. - (void)getUserProfileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
  298. {
  299. [[NCManageDatabase sharedInstance] deleteAccount:metadataNet.account];
  300. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
  301. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  302. [alertController addAction:okAction];
  303. [self presentViewController:alertController animated:YES completion:nil];
  304. }
  305. - (void)getUserProfileSuccess:(CCMetadataNet *)metadataNet userProfile:(OCUserProfile *)userProfile
  306. {
  307. // Verify if the account already exists
  308. if (userProfile.id.length > 0 && self.baseUrl.text.length > 0 && self.user.text.length > 0) {
  309. tableAccount *accountAlreadyExists = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"url = %@ AND user = %@ AND userID != %@", self.baseUrl.text, userProfile.id, self.user.text]];
  310. if (accountAlreadyExists) {
  311. [[NCManageDatabase sharedInstance] deleteAccount:metadataNet.account];
  312. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:[NSString stringWithFormat:NSLocalizedString(@"_account_already_exists_", nil), userProfile.id] preferredStyle:UIAlertControllerStyleAlert];
  313. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  314. [alertController addAction:okAction];
  315. [self presentViewController:alertController animated:YES completion:nil];
  316. return;
  317. }
  318. }
  319. // Verify if account is a valid account
  320. tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", metadataNet.account]];
  321. if (account) {
  322. // Update User (+ userProfile.id)
  323. [[NCManageDatabase sharedInstance] setAccountsUserProfile:userProfile];
  324. // Set this account as default
  325. tableAccount *account = [[NCManageDatabase sharedInstance] setAccountActive:metadataNet.account];
  326. if (account) {
  327. // Setting appDelegate active account
  328. [appDelegate settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activeUserID:account.userID activePassword:account.password];
  329. // Ok ! Dismiss
  330. if ([self.delegate respondsToSelector:@selector(loginSuccess:)])
  331. [self.delegate loginSuccess:_loginType];
  332. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
  333. [self dismissViewControllerAnimated:YES completion:nil];
  334. });
  335. }
  336. }
  337. }
  338. #pragma --------------------------------------------------------------------------------------------
  339. #pragma mark == TextField ==
  340. #pragma --------------------------------------------------------------------------------------------
  341. -(void)textFieldDidBeginEditing:(UITextField *)textField
  342. {
  343. if (textField == self.password) {
  344. self.toggleVisiblePassword.hidden = NO;
  345. self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName: [UIColor darkGrayColor]};
  346. }
  347. }
  348. -(void)textFieldDidEndEditing:(UITextField *)textField
  349. {
  350. if (textField == self.password) {
  351. self.toggleVisiblePassword.hidden = YES;
  352. self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName: [UIColor darkGrayColor]};
  353. }
  354. }
  355. #pragma --------------------------------------------------------------------------------------------
  356. #pragma mark == Action ==
  357. #pragma --------------------------------------------------------------------------------------------
  358. - (void)tabBottomLabel
  359. {
  360. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NCBrandOptions sharedInstance].linkLoginProvider]];
  361. }
  362. - (IBAction)handlebaseUrlchange:(id)sender
  363. {
  364. if ([self.baseUrl.text length] > 0 && !_user.hidden && !_password.hidden)
  365. [self performSelector:@selector(testUrl) withObject:nil];
  366. }
  367. - (IBAction)handleButtonLogin:(id)sender
  368. {
  369. if ([self.baseUrl.text length] > 0 && _user.hidden && _password.hidden) {
  370. [self testUrl];
  371. return;
  372. }
  373. if ([self.baseUrl.text length] > 0 && [self.user.text length] && [self.password.text length]) {
  374. // remove last char if /
  375. if ([[self.baseUrl.text substringFromIndex:[self.baseUrl.text length] - 1] isEqualToString:@"/"])
  376. self.baseUrl.text = [self.baseUrl.text substringToIndex:[self.baseUrl.text length] - 1];
  377. NSString *url = self.baseUrl.text;
  378. NSString *user = self.user.text;
  379. NSString *password = self.password.text;
  380. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
  381. [self loginCloudUrl:url user:user password:password];
  382. });
  383. }
  384. }
  385. - (IBAction)handleAnnulla:(id)sender
  386. {
  387. [self dismissViewControllerAnimated:YES completion:nil];
  388. }
  389. - (IBAction)handleToggleVisiblePassword:(id)sender
  390. {
  391. NSString *currentPassword = self.password.text;
  392. self.password.secureTextEntry = ! self.password.secureTextEntry;
  393. self.password.text = @"";
  394. self.password.text = currentPassword;
  395. self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName: [UIColor darkGrayColor]};
  396. }
  397. - (IBAction)handleLoginTypeView:(id)sender
  398. {
  399. if (_user.hidden && _password.hidden) {
  400. _imageUser.hidden = NO;
  401. _user.hidden = NO;
  402. _imagePassword.hidden = NO;
  403. _password.hidden = NO;
  404. [self.loginTypeView setTitle:NSLocalizedString(@"_web_login_", nil) forState:UIControlStateNormal];
  405. } else {
  406. _imageUser.hidden = YES;
  407. _user.hidden = YES;
  408. _imagePassword.hidden = YES;
  409. _password.hidden = YES;
  410. [self.loginTypeView setTitle:NSLocalizedString(@"_traditional_login_", nil) forState:UIControlStateNormal];
  411. }
  412. }
  413. @end