静态网站,guard内嵌登录,目前用checkLoginStatus检查用户登录状态。
由于guard影响页面加载速度,想看看有没有其他组件可以实现相同功能。
查看文档发现:AuthenticationClient 不支持未能成功调用checkLoginStatus。
不知可否在AuthenticationClient模块下增加该命令,这样就不用每次都加载整个guard了。
静态网站,guard内嵌登录,目前用checkLoginStatus检查用户登录状态。
由于guard影响页面加载速度,想看看有没有其他组件可以实现相同功能。
查看文档发现:AuthenticationClient 不支持未能成功调用checkLoginStatus。
不知可否在AuthenticationClient模块下增加该命令,这样就不用每次都加载整个guard了。
感谢回复,我按如下方式使用报错:Uncaught ReferenceError: Authing is not defined
不知道哪里出了问题
<script src="https://cdn.authing.co/packages/authing-js-sdk/4.23.4/umd/index.js"> </script>
<script>
var authing = new Authing.AuthenticationClient({
appId: '6307583ee3e12de50f9XXXX',
appHost: 'https://diglaws.authing.cn',
})
authing.checkLoginStatus().then(user => {
console.log(user)
})
</script>
你好,以下代码测试是正常的。
替换 CDN 地址、 appId 、 appHost 再看下。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.authing.co/packages/authing-js-sdk/4.23.9/browser/index.min.js"></script>
</head>
<body>
<button id="loginByUsername">loginByUsername</button>
<button id="checkLoginStatus">checkLoginStatus</button>
<button id="logout">logout</button>
<script>
var authenticationClient = new Authing.AuthenticationClient({
appId: '',
appHost: '',
})
document.querySelector('#loginByUsername').onclick = function () {
authenticationClient.loginByUsername('test', '123').then(res => {
console.log('userInfo: ', res)
})
}
document.querySelector('#checkLoginStatus').onclick = function () {
authenticationClient.checkLoginStatus().then(res => {
console.log('loginStatus: ', res)
})
}
document.querySelector('#logout').onclick = function () {
authenticationClient.logout()
}
</script>
</body>
</html>