Skip to content

Commit 539de17

Browse files
committed
保存的时候漏了用户名,吓尿~
1 parent 338d1db commit 539de17

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Coding_iOS/Ease_2FA/Controllers/OTPListViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ - (void)addOneAuthURL:(OTPAuthURL *)authURL{
191191
if ([authURL.name isEqualToString:item.name]) {
192192
alreadyHave = YES;
193193
if ([authURL.otpCode isEqualToString:item.otpCode]) {
194-
kTipAlert(@"该二维码已被保存为账户名:%@", authURL.name);
194+
kTipAlert(@"该二维码已被保存为账户名:\n%@", authURL.name);
195195
}else{
196196
UIAlertView *alertV = [UIAlertView bk_alertViewWithTitle:@"提示" message:[NSString stringWithFormat:@"账户名:%@ 已存在\n选择 '更新' 覆盖原账户。", authURL.name]];
197197
[alertV bk_setCancelButtonWithTitle:@"取消" handler:nil];
@@ -217,7 +217,7 @@ - (void)addOneAuthURL:(OTPAuthURL *)authURL{
217217
[authURL saveToKeychain];
218218
[self.authURLs addObject:authURL];
219219
[self configUI];
220-
kTipAlert(@"添加账户成功:%@", authURL.name);
220+
kTipAlert(@"添加账户成功:\n%@", authURL.name);
221221
}
222222
}
223223

Coding_iOS/Ease_2FA/GoogleOTP/OTPAuthURL.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ + (OTPAuthURL *)ease_authURLWithKeychainDictionary:(NSDictionary *)dict{
152152
OTPAuthURL *authURL = [self authURLWithKeychainDictionary:dict];
153153
if (authURL) {
154154
NSString *secAttrAccount = dict[(__bridge id)kSecAttrAccount];
155-
if (![secAttrAccount isEqualToString:authURL.name]) {
155+
if (secAttrAccount && ![secAttrAccount isEqualToString:authURL.name]) {
156156
authURL.name = secAttrAccount;
157157
}
158158
}
@@ -165,7 +165,7 @@ + (OTPAuthURL *)authURLWithKeychainDictionary:(NSDictionary *)dict {
165165
NSString *urlString = [[NSString alloc] initWithData:urlData
166166
encoding:NSUTF8StringEncoding];
167167
NSString *issuer = dict[(__bridge id)kSecAttrType];
168-
if (issuer.length > 0) {
168+
if (issuer) {
169169
urlString = [urlString stringByAppendingFormat:@"%@=%@", kQueryIssuerKey, issuer];
170170
}
171171
NSURL *url = [NSURL URLWithString:urlString];
@@ -211,11 +211,11 @@ - (BOOL)saveToKeychain {
211211
attributes[(__bridge id)kSecClass] = (__bridge id)kSecClassGenericPassword;
212212
attributes[(__bridge id)kSecReturnPersistentRef] = (id)kCFBooleanTrue;
213213
attributes[(__bridge id)kSecAttrService] = kOTPService;
214-
214+
attributes[(__bridge id)kSecAttrAccount] = self.name;
215215

216216
attributes[(__bridge id)kSecAttrGeneric] = urlData;
217217
attributes[(__bridge id)kSecValueData] = self.generator.secret;
218-
if (self.issuer.length > 0) {
218+
if (self.issuer) {
219219
attributes[(__bridge id)kSecAttrType] = self.issuer;
220220
}
221221

@@ -244,7 +244,7 @@ - (BOOL)hotpUpdateToKeychain{
244244
}
245245

246246
- (BOOL)removeFromKeychain {
247-
if (self.name.length > 0) {
247+
if (self.name) {
248248
NSDictionary *query = [self keychainQuery];
249249
OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);
250250
OTPDevLog(@"SecItemDelete(%@) = %d", query, (int)status);

0 commit comments

Comments
 (0)