Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d9b6195

Browse files
关闭两步验证功能
1 parent 2e654b0 commit d9b6195

File tree

6 files changed

+194
-4
lines changed

6 files changed

+194
-4
lines changed

‎Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
4E53EB521AFA03990034FE1C /* RKSwipeBetweenViewControllers.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E53EB511AFA03990034FE1C /* RKSwipeBetweenViewControllers.m */; };
203203
4E53EB591AFB090E0034FE1C /* nav_page_selected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E53EB571AFB090E0034FE1C /* nav_page_selected@2x.png */; };
204204
4E53EB5A1AFB090E0034FE1C /* nav_page_unselected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E53EB581AFB090E0034FE1C /* nav_page_unselected@2x.png */; };
205+
4E554D6E1C9804F40008686A /* Close2FAViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E554D6D1C9804F40008686A /* Close2FAViewController.m */; };
205206
4E59E1D31A5E6B34004DAEEC /* TaskDescriptionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E59E1D21A5E6B34004DAEEC /* TaskDescriptionViewController.m */; };
206207
4E5A66951B268D160007A0AD /* UIView+PressMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5A66941B268D160007A0AD /* UIView+PressMenu.m */; };
207208
4E5C06E81AC2B34800F427C5 /* tipIcon_BranchMember@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E5C06E71AC2B34800F427C5 /* tipIcon_BranchMember@2x.png */; };
@@ -1377,6 +1378,8 @@
13771378
4E53EB511AFA03990034FE1C /* RKSwipeBetweenViewControllers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKSwipeBetweenViewControllers.m; sourceTree = "<group>"; };
13781379
4E53EB571AFB090E0034FE1C /* nav_page_selected@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "nav_page_selected@2x.png"; sourceTree = "<group>"; };
13791380
4E53EB581AFB090E0034FE1C /* nav_page_unselected@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "nav_page_unselected@2x.png"; sourceTree = "<group>"; };
1381+
4E554D6C1C9804F40008686A /* Close2FAViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Close2FAViewController.h; sourceTree = "<group>"; };
1382+
4E554D6D1C9804F40008686A /* Close2FAViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Close2FAViewController.m; sourceTree = "<group>"; };
13801383
4E59E1D11A5E6B34004DAEEC /* TaskDescriptionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskDescriptionViewController.h; sourceTree = "<group>"; };
13811384
4E59E1D21A5E6B34004DAEEC /* TaskDescriptionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskDescriptionViewController.m; sourceTree = "<group>"; };
13821385
4E5A66931B268D160007A0AD /* UIView+PressMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+PressMenu.h"; sourceTree = "<group>"; };
@@ -4434,6 +4437,8 @@
44344437
4EB52F141C7599FC00B5EBEA /* ActivateViewController.m */,
44354438
4E5C06EC1AC4405300F427C5 /* PasswordViewController.h */,
44364439
4E5C06ED1AC4405300F427C5 /* PasswordViewController.m */,
4440+
4E554D6C1C9804F40008686A /* Close2FAViewController.h */,
4441+
4E554D6D1C9804F40008686A /* Close2FAViewController.m */,
44374442
);
44384443
path = Login;
44394444
sourceTree = "<group>";
@@ -6071,6 +6076,7 @@
60716076
4EBB624D1A6F526C0045DAEF /* NJKWebViewProgressView.m in Sources */,
60726077
4E6383F21B32CC7600D98648 /* TaskActivityCell.m in Sources */,
60736078
4E63189F1BDA199600EFED97 /* MRDetailViewController.m in Sources */,
6079+
4E554D6E1C9804F40008686A /* Close2FAViewController.m in Sources */,
60746080
4ECE8ADA1A3943E80021E29C /* NSDate+Common.m in Sources */,
60756081
8EA6D20A19E240C40076D59C /* RDVTabBar.m in Sources */,
60766082
4E0BD8861B6C7F0A0061CAA6 /* TMCacheExtend.m in Sources */,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// Close2FAViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/3/15.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
11+
@interface Close2FAViewController : BaseViewController
12+
+ (id)vcWithPhone:(NSString *)phone sucessBlock:(void(^)())block;
13+
@end
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
//
2+
// Close2FAViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/3/15.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "Close2FAViewController.h"
10+
#import "Coding_NetAPIManager.h"
11+
#import "TPKeyboardAvoidingTableView.h"
12+
#import "Input_OnlyText_Cell.h"
13+
14+
@interface Close2FAViewController ()<UITableViewDataSource, UITableViewDelegate>
15+
@property (strong, nonatomic) NSString *phone, *phoneCode;
16+
@property (copy, nonatomic) void (^sucessBlock)();
17+
18+
@property (strong, nonatomic) TPKeyboardAvoidingTableView *myTableView;
19+
@property (strong, nonatomic) UIButton *footerBtn;
20+
@property (strong, nonatomic) NSString *phoneCodeCellIdentifier;
21+
@end
22+
23+
@implementation Close2FAViewController
24+
+ (id)vcWithPhone:(NSString *)phone sucessBlock:(void (^)())block{
25+
Close2FAViewController *vc = [self new];
26+
vc.phone = [phone isPhoneNo]? phone: nil;
27+
vc.sucessBlock = block;
28+
return vc;
29+
}
30+
31+
- (void)viewDidLoad {
32+
[super viewDidLoad];
33+
// Do any additional setup after loading the view.
34+
self.title = @"关闭两步验证";
35+
self.phoneCodeCellIdentifier = [Input_OnlyText_Cell randomCellIdentifierOfPhoneCodeType];
36+
37+
// 添加myTableView
38+
_myTableView = ({
39+
TPKeyboardAvoidingTableView *tableView = [[TPKeyboardAvoidingTableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
40+
[tableView registerClass:[Input_OnlyText_Cell class] forCellReuseIdentifier:kCellIdentifier_Input_OnlyText_Cell_Text];
41+
[tableView registerClass:[Input_OnlyText_Cell class] forCellReuseIdentifier:self.phoneCodeCellIdentifier];
42+
tableView.backgroundColor = kColorTableSectionBg;
43+
tableView.dataSource = self;
44+
tableView.delegate = self;
45+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
46+
[self.view addSubview:tableView];
47+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
48+
make.edges.equalTo(self.view);
49+
}];
50+
tableView;
51+
});
52+
self.myTableView.tableHeaderView = [self customHeaderView];
53+
self.myTableView.tableFooterView=[self customFooterView];
54+
}
55+
56+
- (void)viewWillAppear:(BOOL)animated{
57+
[super viewWillAppear:animated];
58+
[self.navigationController setNavigationBarHidden:NO animated:YES];
59+
}
60+
61+
#pragma mark - Table view Header Footer
62+
- (UIView *)customHeaderView{
63+
UIView *headerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 100)];
64+
headerV.backgroundColor = [UIColor clearColor];
65+
UILabel *tipL = [UILabel new];
66+
tipL.font = [UIFont systemFontOfSize:14];
67+
tipL.textColor = [UIColor colorWithHexString:@"0x999999"];
68+
tipL.text = @"关闭两步验证,请先验证您的注册手机";
69+
[headerV addSubview:tipL];
70+
[tipL mas_makeConstraints:^(MASConstraintMaker *make) {
71+
make.center.equalTo(headerV);
72+
}];
73+
return headerV;
74+
}
75+
- (UIView *)customFooterView{
76+
UIView *footerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 150)];
77+
_footerBtn = [UIButton buttonWithStyle:StrapSuccessStyle andTitle:@"关闭两步验证" andFrame:CGRectMake(kLoginPaddingLeftWidth, 20, kScreen_Width-kLoginPaddingLeftWidth*2, 45) target:self action:@selector(footerBtnClicked:)];
78+
[footerV addSubview:_footerBtn];
79+
RAC(self, footerBtn.enabled) = [RACSignal combineLatest:@[RACObserve(self, phone),
80+
RACObserve(self, phoneCode)]
81+
reduce:^id(NSString *phone, NSString *phoneCode){
82+
return @([phone isPhoneNo] && phoneCode.length > 0);
83+
}];
84+
return footerV;
85+
}
86+
#pragma mark - Table view data source
87+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
88+
return 2;
89+
}
90+
91+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
92+
NSString *cellIdentifier = indexPath.row == 1? self.phoneCodeCellIdentifier: kCellIdentifier_Input_OnlyText_Cell_Text;
93+
Input_OnlyText_Cell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
94+
95+
__weak typeof(self) weakSelf = self;
96+
if (indexPath.row == 0) {
97+
[cell setPlaceholder:@" 手机号" value:self.phone];
98+
cell.textField.keyboardType = UIKeyboardTypeNumberPad;
99+
cell.textValueChangedBlock = ^(NSString *valueStr){
100+
weakSelf.phone = valueStr;
101+
};
102+
}else{
103+
cell.textField.keyboardType = UIKeyboardTypeNumberPad;
104+
[cell setPlaceholder:@" 手机验证码" value:self.phoneCode];
105+
cell.textValueChangedBlock = ^(NSString *valueStr){
106+
weakSelf.phoneCode = valueStr;
107+
};
108+
cell.phoneCodeBtnClckedBlock = ^(PhoneCodeButton *btn){
109+
[weakSelf phoneCodeBtnClicked:btn];
110+
};
111+
}
112+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kLoginPaddingLeftWidth];
113+
return cell;
114+
}
115+
116+
#pragma mark Btn Clicked
117+
- (void)phoneCodeBtnClicked:(PhoneCodeButton *)sender{
118+
if (![_phone isPhoneNo]) {
119+
[NSObject showHudTipStr:@"手机号码格式有误"];
120+
return;
121+
}
122+
sender.enabled = NO;
123+
[[Coding_NetAPIManager sharedManager] post_Close2FAGeneratePhoneCode:self.phone block:^(id data, NSError *error) {
124+
if (data) {
125+
[NSObject showHudTipStr:@"验证码发送成功"];
126+
[sender startUpTimer];
127+
}else{
128+
[sender invalidateTimer];
129+
}
130+
}];
131+
}
132+
- (void)footerBtnClicked:(id)sender{
133+
[self.footerBtn startQueryAnimate];
134+
[[Coding_NetAPIManager sharedManager] post_Close2FAWithPhone:self.phone code:self.phoneCode block:^(id data, NSError *error) {
135+
[self.footerBtn stopQueryAnimate];
136+
if (data) {
137+
[NSObject showHudTipStr:@"两步验证已关闭"];
138+
if (self.sucessBlock) {
139+
self.sucessBlock();
140+
}
141+
}
142+
}];
143+
}
144+
@end

‎Coding_iOS/Controllers/Login/LoginViewController.m

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#import <UIImage+BlurredFrame/UIImage+BlurredFrame.h>
1919
#import "UIImageView+WebCache.h"
2020
#import "EaseInputTipsView.h"
21+
#import "Close2FAViewController.h"
2122

2223
#import "Ease_2FA.h"
2324
#import "Login2FATipCell.h"
@@ -30,7 +31,7 @@ @interface LoginViewController ()
3031

3132

3233
@property (assign, nonatomic) BOOL captchaNeeded;
33-
@property (strong, nonatomic) UIButton *loginBtn, *buttonFor2FA;
34+
@property (strong, nonatomic) UIButton *loginBtn, *buttonFor2FA, *cannotLoginBtn;
3435
@property (strong, nonatomic) UIActivityIndicatorView *activityIndicator;
3536
@property (strong, nonatomic) UIImageView *iconUserView, *bgBlurredView;
3637
@property (strong, nonatomic) EaseInputTipsView *inputTipsView;
@@ -325,7 +326,7 @@ - (UIView *)customFooterView{
325326
}
326327
}
327328
}];
328-
UIButton *cannotLoginBtn = ({
329+
_cannotLoginBtn = ({
329330
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
330331
[button.titleLabel setFont:[UIFont systemFontOfSize:14]];
331332
[button setTitleColor:[UIColor colorWithWhite:1.0 alpha:0.5] forState:UIControlStateNormal];
@@ -340,7 +341,7 @@ - (UIView *)customFooterView{
340341
}];
341342
button;
342343
});
343-
[cannotLoginBtn addTarget:self action:@selector(cannotLoginBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
344+
[_cannotLoginBtn addTarget:self action:@selector(cannotLoginBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
344345

345346
return footerV;
346347
}
@@ -456,7 +457,15 @@ - (void)sendActivateEmail{
456457
}
457458

458459
- (IBAction)cannotLoginBtnClicked:(id)sender {
459-
CannotLoginViewController *vc = [CannotLoginViewController vcWithMethodType:0 stepIndex:0 userStr:(([self.myLogin.email isPhoneNo] || [self.myLogin.email isEmail])? self.myLogin.email: nil)];
460+
UIViewController *vc;
461+
if (_is2FAUI) {
462+
vc = [Close2FAViewController vcWithPhone:self.myLogin.email sucessBlock:^{
463+
self.is2FAUI = NO;
464+
[self.navigationController popToRootViewControllerAnimated:YES];
465+
}];
466+
}else{
467+
vc = [CannotLoginViewController vcWithMethodType:0 stepIndex:0 userStr:(([self.myLogin.email isPhoneNo] || [self.myLogin.email isEmail])? self.myLogin.email: nil)];
468+
}
460469
[self.navigationController pushViewController:vc animated:YES];
461470
}
462471

@@ -490,6 +499,8 @@ - (void)setIs2FAUI:(BOOL)is2FAUI{
490499
}else{
491500
[self.dismissButton setImage:[UIImage imageNamed:@"backBtn_Nav"] forState:UIControlStateNormal];
492501
}
502+
[_cannotLoginBtn setTitle:_is2FAUI? @"关闭两步验证": @"找回密码" forState:UIControlStateNormal];
503+
493504
[self.myTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:_is2FAUI? UITableViewRowAnimationLeft: UITableViewRowAnimationRight];
494505
}
495506

‎Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ typedef NS_ENUM(NSInteger, PurposeType) {
243243
- (void)request_Users_WithTopicID:(NSInteger)topicID andBlock:(void (^)(id data, NSError *error))block;
244244
- (void)request_JoinedUsers_WithTopicID:(NSInteger)topicID page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;
245245

246+
#pragma mark - 2FA
247+
- (void)post_Close2FAGeneratePhoneCode:(NSString *)phone block:(void (^)(id data, NSError *error))block;
248+
- (void)post_Close2FAWithPhone:(NSString *)phone code:(NSString *)code block:(void (^)(id data, NSError *error))block;
246249

247250
#pragma mark - Topic HotKey
248251
- (void)request_TopicHotkeyWithBlock:(void (^)(id data, NSError *error))block;

‎Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,6 +2563,19 @@ - (void)request_VerifyTypeWithBlock:(void (^)(VerifyType type, NSError *error))b
25632563
}];
25642564
}
25652565

2566+
#pragma mark - 2FA
2567+
- (void)post_Close2FAGeneratePhoneCode:(NSString *)phone block:(void (^)(id data, NSError *error))block{
2568+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/twofa/close/code" withParams:@{@"phone": phone, @"from": @"mart"} withMethodType:Post andBlock:^(id data, NSError *error) {
2569+
block(data, error);
2570+
}];
2571+
}
2572+
2573+
- (void)post_Close2FAWithPhone:(NSString *)phone code:(NSString *)code block:(void (^)(id data, NSError *error))block{
2574+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/twofa/close" withParams:@{@"phone": phone, @"code": code} withMethodType:Post andBlock:^(id data, NSError *error) {
2575+
block(data, error);
2576+
}];
2577+
}
2578+
25662579
#pragma mark -
25672580
#pragma mark Topic HotKey
25682581

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /