从firebase.auth()。currentUser.getIdToken方法成功登录后,我从客户端SDK获取idToken。我不想将此令牌通过AJAX发送到一个特定的请求,而是希望将其发送到中间件,以便可以检查所有请求以查看是否允许该用户。有道理吗?
服务器JS
var express = require('express');
var router = express.Router();
// firebase
var admin = require('firebase-admin');
var serviceAccount = require('../delbay-restaurant-firebase-adminsdk-bqkir-481ca82589.json');
// Initialize only once in the app cycle
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://delbay-restaurant.firebaseio.com"
});
function isAuthenticated(req, res, next) {
}
router.get('/', isAuthenticated, function(req, res, next) {
res.render("user");
});
module.exports = router;