我一直在使用aws-amplify离子库,并想知道如何检查用户是否登录?我来自firebase背景所以这是完全不同的.这样我就可以根据用户的登录状态授予对某些页面的访问权限.在我的auth提供者中我导入Amplify {Auth}.我可以看到可以获得几个数据,但我不知道该使用什么.有currentUserPoolUser,getCurrentUser(),getSyncedUser(),currentAuthenticatedUser,currentSession,getCurrentUser(),userSession,currentUserCredentials,currentCredentials和currentUserInfo.我似乎无法找到任何这方面的任何文件.我阅读和观看的所有内容都会被覆盖,直到用户登录...这一切都应该在客户端完成吗?谢谢.
Invalid register options "value" must be an object每当我尝试运行hapi服务器时,我都会收到一个奇怪的错误.我似乎无法弄清楚这个问题.这是我的代码:
await server.register(require('hapi-auth-jwt2'), (err) => {
if (err) console.log(err);
server.auth.strategy('jwt', 'jwt', {
key: secretKey,
verifyOptions: { algorithms: ['HS256'] }
});
glob.sync('api/**/routes/*.js', {
root: __dirname
}).forEach(file => {
const route = require(path.join(__dirname, file));
server.route(route);
});
}).catch(err => {
console.log(err);
});
Run Code Online (Sandbox Code Playgroud)
我也尝试了这个,我仍然得到错误:
const options = {
key: secretKey,
verifyOptions: { algorithms: ['HS256'] }
};
await server.register({
register: require('hapi-auth-jwt2'),
options
}, (err) => {
if (err) console.log(err);
// We're giving the strategy both a name …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用这里的代码示例https://github.com/firebase/functions-samples/blob/master/authorized-https-endpoint/functions/index.js但我的云功能不断崩溃说
req.headers.split is not a function
at cors (/user_code/index.js:25:37)
at cors (/user_code/node_modules/cors/lib/index.js:188:7)
at /user_code/node_modules/cors/lib/index.js:224:17
at originCallback (/user_code/node_modules/cors/lib/index.js:214:15)
at /user_code/node_modules/cors/lib/index.js:219:13
at optionsCallback (/user_code/node_modules/cors/lib/index.js:199:9)
at corsMiddleware (/user_code/node_modules/cors/lib/index.js:204:7)
at exports.savedProfiles.functions.https.onRequest (/user_code/index.js:14:5)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:26:41)
at /var/tmp/worker/worker.js:671:7
Run Code Online (Sandbox Code Playgroud)
我不知道还有什么办法让它发挥作用。这是我到目前为止使用过的代码:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors')({origin: true});
exports.savedProfiles = functions.https.onRequest((req, res) => {
cors(req, res, () => {
if ((!req.headers.authorization || !req.headers.authorization.includes('Bearer '))) {
console.log(req.headers);
console.error('No Firebase ID token was passed as a Bearer token in the Authorization …Run Code Online (Sandbox Code Playgroud) javascript firebase firebase-authentication google-cloud-functions
<nav id="main_nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Forum</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
#main_nav{
background:green;
}
#main_nav li{
display:inline-block;
list-style:none;
padding:10px;
font-weight:bold;
}
#main_nav li a{
text-decoration: none;
color:white;
padding:10px;
}
#main_nav li{
-webkit-transition: opacity .5s, background .5s, color .5s;
-moz-transition: opacity .5s, background .5s, color .5s;
-o-transition: opacity .5s, background .5s, color .5s;
}
#main_nav li:hover{
color:red;
background:rgba(0, 0, 200,.5);
}
Run Code Online (Sandbox Code Playgroud)
这是我的导航栏,但我有问题.每个链接之间是一个很小的空间.当我快速地将它们悬停在它们上面时,它看起来并不好看.我该如何删除它?