ConfirmPwdViewController.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // ConfirmPwdViewController.h
  3. // kneet
  4. //
  5. // Created by Jason Lee on 5/13/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "JDJSONModel.h"
  11. #import "ValidateUtil.h"
  12. #import "CustomTextField.h"
  13. #import "PwdPopupView.h"
  14. #import "ConfirmPwdViewController.h"
  15. #import "DeleteAccountPopupView.h"
  16. @interface ConfirmPwdViewController () <CustomTextFieldDelegate> {
  17. }
  18. @end
  19. #pragma mark - Class Definition
  20. @implementation ConfirmPwdViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. [self initUI];
  25. [self prepareViewDidLoad];
  26. }
  27. - (void)initUI {
  28. self.title = NSLocalizedString(@"비밀번호 확인",nil);
  29. _txtUserPwd.delegate = self;
  30. _txtUserPwd.customTextFieldSuperview = CustomTextFieldSuperviewIsScrollView;
  31. _txtUserPwd.secureTextEntry = YES;
  32. _txtUserPwd.keyboardType = UIKeyboardTypeDefault;
  33. _txtUserPwd.returnKeyType = UIReturnKeyDone;
  34. _txtUserPwd.placeholder = NSLocalizedString(@"비밀번호 입력", @"비밀번호 입력");
  35. _lblTitle.text = @"본인확인을 위해 비밀번호를\n입력해주세요";
  36. [_btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  37. [_btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  38. }
  39. - (void)prepareViewDidLoad {
  40. }
  41. #pragma mark - Main Logic
  42. - (void)requestCheckPassword {
  43. //parameters
  44. NSDictionary *parameter = @{@"password": _txtUserPwd.text};
  45. NSString *path = [NSString stringWithFormat:API_GET_CHECK_PWD, [JDFacade facade].loginUser.memberId];
  46. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
  47. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  48. return;
  49. }
  50. JDJSONModel *result = (JDJSONModel *) responseObject;
  51. if (result) {//API 성공 ,
  52. [self loadPopupView];
  53. }
  54. } failure:^(id errorObject) {
  55. JDErrorModel *error = (JDErrorModel *)errorObject;
  56. [[JDFacade facade] alert:error.errorMessage];
  57. }];
  58. }
  59. - (void)loadPopupView {
  60. CustomAlertView *popup = [[NSClassFromString(_popupName) alloc] initFromNib];
  61. if ([popup isKindOfClass:[PwdPopupView class]]) {
  62. } else if ([popup isKindOfClass:[DeleteAccountPopupView class]]) {
  63. ((DeleteAccountPopupView *)popup).passwd = _txtUserPwd.text;
  64. }
  65. [popup showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  66. [self.navigationController popViewControllerAnimated:YES];
  67. }];
  68. }
  69. #pragma mark - UI Events
  70. - (IBAction)btnConfirmTouched:(id)sender {
  71. #ifdef DEBUG_MODE
  72. if ([_txtUserPwd.text isEmptyString]) {
  73. _txtUserPwd.text = @"goj132!#@";
  74. }
  75. #else
  76. //validate
  77. if (![ValidateUtil validateTextfiled:_txtUserPwd type:ValidateTypeNull title:NSLocalizedString(@"비밀번호", @"비밀번호")]) {
  78. return;
  79. }
  80. #endif
  81. [self requestCheckPassword];
  82. }
  83. - (IBAction)btnCancelTouched:(id)sender {
  84. [self.navigationController popViewControllerAnimated:YES];
  85. }
  86. #pragma mark - CustomTextField
  87. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  88. [self btnConfirmTouched:nil];
  89. return YES;
  90. }
  91. #pragma mark - MemoryWarning
  92. - (void)didReceiveMemoryWarning
  93. {
  94. [super didReceiveMemoryWarning];
  95. // Dispose of any resources that can be recreated.
  96. }
  97. @end