DeleteAccountPopupView.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // DeleteAccountPopupView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 5/12/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "JDJSONModel.h"
  11. #import "CustomLabel.h"
  12. #import "DeleteAccountPopupView.h"
  13. #import "KeychainItemWrapper.h"
  14. @interface DeleteAccountPopupView () {
  15. }
  16. @end
  17. @implementation DeleteAccountPopupView
  18. - (id)initFromNib {
  19. for (UIView *view in [CommonUtil nibViews:@"DeleteAccountPopupView"]) {
  20. if ([view isKindOfClass:[DeleteAccountPopupView class]]) {
  21. self = (DeleteAccountPopupView *)view;
  22. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  23. self.frame = [UIScreen mainScreen].bounds;
  24. self.lblTitle.text = NSLocalizedString(@"계정 삭제",nil);
  25. [_lblWarning setUnderLine:_lblWarning.text];
  26. //Localization
  27. _lblDesc1.text = NSLocalizedString(@"계정을 삭제한 즉시\n모든 장치와 규칙이 사라집니다", @"계정을 삭제한 즉시\n모든 장치와 규칙이 사라집니다");
  28. _lblDesc2.text = NSLocalizedString(@"삭제 후에는 복구할 수 없으며\n새로운 계정을 만들고\n장치를 등록해야 합니다", @"삭제 후에는 복구할 수 없으며\n새로운 계정을 만들고\n장치를 등록해야 합니다");
  29. _lblDesc3.text = NSLocalizedString(@"신중하게 결정해주세요", @"신중하게 결정해주세요");
  30. //Localization
  31. [self.btnConfirm setTitle:NSLocalizedString(@"계정삭제", @"계정삭제") forState:UIControlStateNormal];
  32. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  33. }
  34. }
  35. return self;
  36. }
  37. - (void)didMoveToSuperview {
  38. }
  39. //계정 삭제
  40. - (void)requestDeleteAccount {
  41. NSString *path = [NSString stringWithFormat:API_DELETE_ACCOUNT, [JDFacade facade].loginUser.memberId];
  42. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  43. //자동 로그인 설정 - 취소
  44. [[JDFacade facade] storeObjectToUserDefaults:@NO forKey:USER_DEF_AUTO_LOGIN];
  45. KeychainItemWrapper *_keychainItemWrapper = [[KeychainItemWrapper alloc] initWithIdentifier:USER_DEF_AUTOTOKEN accessGroup:nil];
  46. // save AuthToken in keychain
  47. [_keychainItemWrapper setObject:nil forKey:(__bridge id)(kSecAttrAccount)];
  48. [JDFacade facade].loginUser = nil;
  49. [JDFacade facade].loginHomeGroup = nil;
  50. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"GoodbyeViewController" storyboardName:@"Settings"];
  51. [[JDFacade facade] presentViewControllerByPush:vc];
  52. [super btnConfirmTouched:nil];
  53. } failure:^(id errorObject) {
  54. JDErrorModel *error = (JDErrorModel *)errorObject;
  55. [[JDFacade facade] alert:error.errorMessage];
  56. }];
  57. }
  58. - (void)btnConfirmTouched:(id)sender {
  59. [self requestDeleteAccount];
  60. }
  61. @end