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 7117c56

Browse files
扫一扫中添加对两步验证码的处理
1 parent f380a3a commit 7117c56

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

‎Coding_iOS/Controllers/RootControllers/Project_RootViewController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#import "FRDLivelyButton.h"
3232
#import "StartImagesManager.h"
3333
#import "ZXScanCodeViewController.h"
34+
#import "OTPListViewController.h"
3435
#import "WebViewController.h"
3536

3637
@interface Project_RootViewController ()<UISearchBarDelegate, UITableViewDataSource, UITableViewDelegate>
@@ -616,11 +617,14 @@ - (void)scanBtnClicked{
616617
}
617618

618619
- (void)dealWithScanResult:(NSString *)resultStr ofVC:(ZXScanCodeViewController *)vc{
620+
if ([OTPListViewController handleScanResult:resultStr ofVC:vc]) {
621+
return;
622+
}
619623
UIViewController *nextVC = [BaseViewController analyseVCFromLinkStr:resultStr];
620624
NSURL *URL = [NSURL URLWithString:resultStr];
621625
if (nextVC) {
622626
[self.navigationController pushViewController:nextVC animated:YES];
623-
}else if (URL){
627+
}else if ([[UIApplication sharedApplication] canOpenURL:URL]){
624628
UIAlertView *alertV = [UIAlertView bk_alertViewWithTitle:@"提示" message:[NSString stringWithFormat:@"可能存在风险,是否打开此链接?\n%@", resultStr]];
625629
[alertV bk_setCancelButtonWithTitle:@"取消" handler:nil];
626630
[alertV bk_addButtonWithTitle:@"打开链接" handler:nil];

‎Coding_iOS/Ease_2FA/Controllers/OTPListViewController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
#import "BaseViewController.h"
1010

1111
@interface OTPListViewController : BaseViewController
12-
+(NSString *)otpCodeWithGK:(NSString *)global_key;
12+
+ (NSString *)otpCodeWithGK:(NSString *)global_key;
13+
+ (BOOL)handleScanResult:(NSString *)resultStr ofVC:(UIViewController *)vc;
1314
@end

‎Coding_iOS/Ease_2FA/Controllers/OTPListViewController.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
#import "OTPListViewController.h"
10-
#import "ZXScanCodeViewController.h"
1110
#import "OTPTableViewCell.h"
1211

1312
#import "OTPAuthURL.h"
@@ -60,7 +59,7 @@ + (NSMutableArray *)loadKeychainAuthURLs{
6059
return authURLs;
6160
}
6261

63-
+(NSString *)otpCodeWithGK:(NSString *)global_key{
62+
+(NSString *)otpCodeWithGK:(NSString *)global_key{
6463
NSString *otpCode = nil;
6564
if (global_key.length > 0) {
6665
NSMutableArray *authURLs = [self loadKeychainAuthURLs];
@@ -77,6 +76,18 @@ +(NSString *)otpCodeWithGK:(NSString *)global_key{
7776
return otpCode;
7877
}
7978

79+
+ (BOOL)handleScanResult:(NSString *)resultStr ofVC:(UIViewController *)vc{
80+
//解析结果
81+
OTPAuthURL *authURL = [OTPAuthURL authURLWithURL:[NSURL URLWithString:resultStr] secret:nil];
82+
if ([authURL isKindOfClass:[TOTPAuthURL class]]) {
83+
OTPListViewController *nextVC = [OTPListViewController new];
84+
[vc.navigationController pushViewController:nextVC animated:YES];
85+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
86+
[nextVC addOneAuthURL:authURL];
87+
});
88+
}
89+
}
90+
8091
- (void)viewDidLoad{
8192
[super viewDidLoad];
8293
self.title = @"身份验证器";

0 commit comments

Comments
(0)

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