简体   繁体   English

Google Smartlock:PromiseStatus 时该怎么办:通过控制台中的 Javascript 挂起

[英]Google Smartlock: what to do when PromiseStatus: pending via Javascript in console

we are integrating Google Smartlock.我们正在集成 Google Smartlock。 Every time we run the JS code to enable Smart lock on 1 screen it does nothing at all.每次我们运行 JS 代码以在 1 个屏幕上启用智能锁定时,它什么都不做。 And when we trigger it manually we only see this in console log.当我们手动触发它时,我们只能在控制台日志中看到这一点。

Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}

javascript is like this 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>

Question : Does anyone know what is happening here?问题:有谁知道这里发生了什么?

I tested with 1 saved passwd, with 2 saved passwd's.我测试了 1 个保存的密码,2 个保存的密码。 We do see the small key icon next to the URL in Chrome.我们确实在 Chrome 中的 URL 旁边看到了小钥匙图标。 But it doesn't popup or do anything.但它不会弹出或做任何事情。

Help/advise appreciated帮助/建议表示赞赏

在此处输入图片说明

在此处输入图片说明

References: https://support.google.com/accounts/answer/6160273?hl=en参考资料: https : //support.google.com/accounts/answer/6160273?hl=en

It looks like you're requesting unmediated: true which forces the browser to not show the account selector UI.看起来您正在请求unmediated: true ,这会强制浏览器不显示帐户选择器 UI。

When you have more than one credentials stored or one credential that requires user mediation, get(...) returns undefined unless you allow the mediation ( unmediated: false which is default).当您存储了多个凭据或一个需要用户中介的凭据时,除非您允许中介( unmediated: false ,这是默认值),否则get(...)将返回undefined

Note: Your credentials should require mediation when the user signs out of an account ( navigator.credentials.requireUserMediation() ).注意:当用户注销帐户 ( navigator.credentials.requireUserMediation() ) 时,您的凭据应该需要中介。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 承诺待定,promisestatus =已解决? - Promise pending, promisestatus=resolved? Element.getAttribute() 将 promisestatus 返回为待处理:protractor - Element.getAttribute() returning promisestatus as Pending : protractor 硒-{[[PromiseStatus]]:“待定”}没有方法&#39;indexOf&#39; - Selenium - {[[PromiseStatus]]: “pending”} has no method 'indexOf' selenium:ManagedPromise :: 32 {[[PromiseStatus]]:“待处理”}消息,然后导航到页面 - selenium: ManagedPromise::32 {[[PromiseStatus]]: “pending”} message shown before navigating to the page 承诺A +实现:当调用then()并且承诺仍然未决时该怎么办? - Promise A+ Implementation: what to do when call then() and the promise is still pending? Google Smartlock / Googleyolo未返回保存的密码 - Google Smartlock/Googleyolo did not return saved password ||是什么 在javascript的console.log()中做什么? - What does || do in console.log() in javascript? 当javascript控制台显示带有#2的圆圈时是什么意思 - what it means when javascript console shows a circle with #2 如何通过控制台检查 Google Forms 复选框? - How do I check Google Forms checkbox via console? 当控制台报告jquery中的错误时,如何确定javascript的哪一行导致IE中的此错误? - How do I determine what line of my javascript is causing this error in IE, when the console reports the bug is in jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM