SignUpViewController.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // SignUpViewController.m
  3. // HMLG Scan Order
  4. //
  5. // Created by Rui Zhang on 4/7/22.
  6. // Copyright © 2022 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "SignUpViewController.h"
  9. #import "RAUtils.h"
  10. #import "RADataProvider.h"
  11. @interface SignUpViewController ()
  12. @end
  13. @implementation SignUpViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view.
  17. }
  18. - (IBAction)onSignUpClick:(id)sender {
  19. NSString* user = self.editUser.text;
  20. NSString* email = self.editEmail.text;
  21. NSString* pwd = self.editpwd.text;
  22. NSString* cpwd = self.editcpwd.text;
  23. if(![RAUtils validateEmail:email])
  24. {
  25. [RAUtils message_box:@"Warrning" message:@"Email invalidate" completion:nil];
  26. return;
  27. }
  28. if(![RAUtils checkPassword:pwd])
  29. {
  30. [RAUtils message_box:@"Warrning" message:@"Password must be 8-16 characters and contain numbers and letters." completion:nil];
  31. return;
  32. }
  33. if(![pwd isEqualToString:cpwd])
  34. {
  35. [RAUtils message_box:@"Warrning" message:@"Password does not equal" completion:nil];
  36. return;
  37. }
  38. // __block UIAlertController * waitalert =[RAUtils waiting_alert:self title:@"Sign Up" completion:nil];
  39. PopWaitAlert * pop = [RAUtils waiting_pop:@"Sign Up" completion:nil];
  40. dispatch_async(dispatch_get_main_queue(), ^{
  41. [RADataProvider request_sign_up:user email:email password:pwd completionHandler:^(NSMutableDictionary *result) {
  42. // [waitalert dismissViewControllerAnimated:true completion:^{
  43. [pop hide];
  44. NSMutableDictionary* return_json = result;
  45. if([[return_json valueForKey:@"result"] intValue]==2)
  46. {
  47. [RAUtils message_box:@"Sign Up" message:@"Sign Up Successful" completion:^{
  48. [self dismissViewControllerAnimated:true completion:nil];
  49. }];
  50. }
  51. else
  52. {
  53. [RAUtils message_box:@"Sign Up" message:[return_json valueForKey:@"err_msg"] completion:nil];
  54. }
  55. // }];
  56. }];
  57. });
  58. }
  59. - (IBAction)onCloseClick:(id)sender {
  60. [self dismissViewControllerAnimated:true completion:nil];
  61. }
  62. /*
  63. #pragma mark - Navigation
  64. // In a storyboard-based application, you will often want to do a little preparation before navigation
  65. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  66. // Get the new view controller using [segue destinationViewController].
  67. // Pass the selected object to the new view controller.
  68. }
  69. */
  70. @end