| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // DeleteAccountPopupView.m
- // kneet
- //
- // Created by Jason Lee on 5/12/15.
- // Copyright (c) 2015 ntels. All rights reserved.
- //
- #import "JDObject.h"
- #import "RequestHandler.h"
- #import "JDJSONModel.h"
- #import "CustomLabel.h"
- #import "DeleteAccountPopupView.h"
- #import "KeychainItemWrapper.h"
- @interface DeleteAccountPopupView () {
- }
- @end
- @implementation DeleteAccountPopupView
- - (id)initFromNib {
- for (UIView *view in [CommonUtil nibViews:@"DeleteAccountPopupView"]) {
- if ([view isKindOfClass:[DeleteAccountPopupView class]]) {
- self = (DeleteAccountPopupView *)view;
- //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
- self.frame = [UIScreen mainScreen].bounds;
- self.lblTitle.text = NSLocalizedString(@"계정 삭제",nil);
- [_lblWarning setUnderLine:_lblWarning.text];
-
- //Localization
- _lblDesc1.text = NSLocalizedString(@"계정을 삭제한 즉시\n모든 장치와 규칙이 사라집니다", @"계정을 삭제한 즉시\n모든 장치와 규칙이 사라집니다");
- _lblDesc2.text = NSLocalizedString(@"삭제 후에는 복구할 수 없으며\n새로운 계정을 만들고\n장치를 등록해야 합니다", @"삭제 후에는 복구할 수 없으며\n새로운 계정을 만들고\n장치를 등록해야 합니다");
- _lblDesc3.text = NSLocalizedString(@"신중하게 결정해주세요", @"신중하게 결정해주세요");
-
- //Localization
- [self.btnConfirm setTitle:NSLocalizedString(@"계정삭제", @"계정삭제") forState:UIControlStateNormal];
- [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
- }
- }
- return self;
- }
- - (void)didMoveToSuperview {
- }
- //계정 삭제
- - (void)requestDeleteAccount {
- NSString *path = [NSString stringWithFormat:API_DELETE_ACCOUNT, [JDFacade facade].loginUser.memberId];
- [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
- //자동 로그인 설정 - 취소
- [[JDFacade facade] storeObjectToUserDefaults:@NO forKey:USER_DEF_AUTO_LOGIN];
- KeychainItemWrapper *_keychainItemWrapper = [[KeychainItemWrapper alloc] initWithIdentifier:USER_DEF_AUTOTOKEN accessGroup:nil];
- // save AuthToken in keychain
- [_keychainItemWrapper setObject:nil forKey:(__bridge id)(kSecAttrAccount)];
- [JDFacade facade].loginUser = nil;
- [JDFacade facade].loginHomeGroup = nil;
-
- UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"GoodbyeViewController" storyboardName:@"Settings"];
- [[JDFacade facade] presentViewControllerByPush:vc];
- [super btnConfirmTouched:nil];
-
- } failure:^(id errorObject) {
- JDErrorModel *error = (JDErrorModel *)errorObject;
- [[JDFacade facade] alert:error.errorMessage];
- }];
- }
- - (void)btnConfirmTouched:(id)sender {
- [self requestDeleteAccount];
- }
- @end
|