狀況:我的Firebase網站只允許一個用戶隨時登錄,爲什麼?
如果我從一個設備登錄並打開該網站進行任何其他設備(我的電話,我的朋友的筆記本電腦,我的鄰居的PC)上,該網站顯示我的登錄所有這些設備。
如果我註銷,我顯示爲在所有設備上註銷。
實際上,我的網站只能由一個用戶在一個毫無意義的時間使用。
我必須以某種方式濫用Firebase身份驗證。
CODE:
router.post('/login', function(req, res, next) {
var email = req.body.email;
var password = req.body.password;
// Validation
req.checkBody('email', 'Email is required').notEmpty();
req.checkBody('email', 'Email is not valid').isEmail();
req.checkBody('password', 'Password is required').notEmpty();
var errors = req.validationErrors();
if(errors){
res.render('users/login', {
errors: errors
});
} else {
firebase.auth().signInWithEmailAndPassword(email, password).then(authData => {
console.log("Authenticated user with uid:",authData);
req.flash('success_msg', 'You have logged in');
res.redirect("/fun/index");
}).catch(error => {
var errorCode = error.code;
var errorMessage = error.message;
console.log("Login Failed: ", error);
req.flash('error_msg', "Unknown user or password");
res.redirect('/users/login');
});
}
});
問題:
我已做和如何解決它有什麼錯?
編輯:發現這一點:Firebase NodeJS Authentication
但問題仍然沒有答案。
由於您似乎選擇在服務器上登錄用戶,因此無法輕鬆修復。一個初始化的Firebase API應用只能有一個登錄用戶,這就是您的問題。我隱約記住,這是在發佈到您之前的問題之一的評論中提到的。 – cartant
@cartant也許這與在客戶端登錄一樣簡單? – Coder1000