gpt4 book ai didi

ios - SecRequestSharedWebCredential 凭据包含 'Passwords not saved' ?

转载 作者:可可西里 更新时间:2023-11-01 06:02:43 25 4
gpt4 key购买 nike

我们通过函数检索所有保存的密码:

SecRequestSharedWebCredential(NULL, NULL, ^(CFArrayRef credentials, CFErrorRef error) {
if (!error && CFArrayGetCount(credentials)) {
CFDictionaryRef credential = CFArrayGetValueAtIndex(credentials, 0);
if (credential > 0) {
CFDictionaryRef credential = CFArrayGetValueAtIndex(credentials, 0);
NSString *username = CFDictionaryGetValue(credential, kSecAttrAccount);
NSString *password = CFDictionaryGetValue(credential, kSecSharedPassword);
dispatch_async(dispatch_get_main_queue(), ^{
//Updates the UI here.
});
}
}
});

问题是,在 IOS 9.3.3 iPhone 6 A1524 上,我们会收到一个名为“未保存密码”的条目的提示。没有错误消息提示未找到密码。因为数组 > 0,所以它用条目完成表单。

为什么会这样?我们认为如果您的授权域下没有存储密码,则不会出现提示。

有什么建议吗?

谢谢。

最佳答案

我在 viewDidLoad() 中为我的 Auth View Controller 检查这个。该代码与上面的代码略有不同,是从其他几个 SO 答案中收集的。

swift 3:

SecRequestSharedWebCredential(Configuration.webBaseFQDN as CFString, nil, { (credentials, error) in

if let error = error {
print("ERROR: credentials")
print(error)
}

guard let credentials = credentials, CFArrayGetCount(credentials) > 0 else {
// Did not find a shared web credential.
return
}

guard CFArrayGetCount(credentials) == 1 else {
// There should be exactly one credential.
return
}

let unsafeCredential = CFArrayGetValueAtIndex(credentials, 0)
let credential = unsafeBitCast(unsafeCredential, to: CFDictionary.self)

let unsafeEmail = CFDictionaryGetValue(credential, Unmanaged.passUnretained(kSecAttrAccount).toOpaque())
let email = unsafeBitCast(unsafeEmail, to: CFString.self) as String

let unsafePassword = CFDictionaryGetValue(credential, Unmanaged.passUnretained(kSecSharedPassword).toOpaque())
let password = unsafeBitCast(unsafePassword, to: CFString.self) as String

if self.isValidEmail(email) && self.isValidPassword(password) {
self.usedSharedWebCredentials = true
self.doSignIn(email: email, password: password)
}
})

isValidEmail(_:)isValidPassword(_:) 最后的额外检查处理了 SecRequeestSharedWebCredential() 返回的情况第一个凭据(电子邮件)中的“密码未保存”。

希望有人能解释为什么会发生这种情况,但如果没有,至少有一种方法可以解决这种情况。

我还想补充一点,我在 iOS 10.2.1 之前就已经看到了这一点

关于ios - SecRequestSharedWebCredential 凭据包含 'Passwords not saved' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38698565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com