| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- //
- // ChangePasswordViewController.m
- // HMLG Scan Order
- //
- // Created by Rui Zhang on 4/8/22.
- // Copyright © 2022 United Software Applications, Inc. All rights reserved.
- //
- #import "ChangePasswordViewController.h"
- #import "AppDelegate.h"
- #import "RAUtils.h"
- #import "RADataProvider.h"
- @interface ChangePasswordViewController ()
- @end
- @implementation ChangePasswordViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- }
- - (IBAction)onChangeClick:(id)sender {
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // if(appDelegate.user.length==0)
- // {
- // [RAUtils message_alert:@"You must sign in first." title:@"Delete Account" controller:self];
- // return;
- // }
- NSString* opwd = self.editopwd.text;
-
- NSString* pwd = self.editnpwd.text;
- NSString* cpwd = self.editcpwd.text;
-
- if(![opwd isEqualToString: appDelegate.password])
- {
- [RAUtils message_alert:@"Password incorrect." title:@"Warrning" controller:self];
- return;
- }
- if(![RAUtils checkPassword:pwd])
- {
- [RAUtils message_alert:@"Password must be 8-16 characters and contain numbers and letters." title:@"Warrning" controller:self];
- return;
- }
- if(![pwd isEqualToString:cpwd])
- {
- [RAUtils message_alert:@"Password does not equal" title:@"Warrning" controller:self];
- return;
- }
- __block UIAlertController * waitalert =[RAUtils waiting_alert:self title:@"Change Password" completion:nil];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [RADataProvider request_change_password:pwd completionHandler:^(NSMutableDictionary *result) {
- [waitalert dismissViewControllerAnimated:true completion:^{
- NSMutableDictionary* return_json = result;
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
-
- [RAUtils message_alert:@"Change password successful" title:@"Change Password" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
- appDelegate.password = pwd;
- [self dismissViewControllerAnimated:true completion:nil];
- } completion:nil];
- }
- else
- {
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Change Password" controller:self] ;
- }
- }];
- }];
- });
- }
- - (IBAction)onCloseClick:(id)sender {
- [self dismissViewControllerAnimated:true completion:nil];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|