我们正在集成 Google Smartlock。每次我们运行 JS 代码以在 1 个屏幕上启用智能锁定时,它什么都不做。当我们手动触发它时,我们只能在控制台日志中看到它。
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
javascript是这样的
<script>
window.onload=function(e){
var debug = true;
var always = function() { console.log('Promise resolved: but dont understand how should process: we want/need to login') }
navigator.credentials.get({password: true, unmediated: true, }).then(function(cred) {
if (cred) {
if (cred.type == 'password') {
var form = new FormData();
cred.additionalData = form;
var url = 'domain.com/login';
fetch(url, {method: 'POST', credentials: cred }).then(function(response) {
if (response.status == 202) {
if (debug) { console.log('Login success; reload stopped'); exit; }
window.location.reload();
}
if (debug) { console.log('Server status: ' + response.status); }
return;
}).catch(function(err) { console.log('Smartlock Ajax error:'+ err);
}).then(always, always);
} // can add federated here
} else if (typeof cred === "undefined") {
// user clicks cancel or no credentials found
var expiry = new Date(); expiry.setDate(expiry.getDate() + (1/3600*30));
document.cookie="dontshowagain=true; expires=" + expiry.toGMTString();
}
});
}
</script>
问题:有谁知道这里发生了什么?
我用 1 个保存的 passwd 和 2 个保存的 passwd 进行了测试。我们确实在 Chrome 中的 URL 旁边看到了小钥匙图标。但它不会弹出或做任何事情。
帮助/建议赞赏
参考资料: https ://support.google.com/accounts/answer/6160273?hl=en