Firebase身份验证:用户会话已携带到其他浏览器

时间:2019-02-05 07:47:00

标签: javascript node.js firebase-authentication

假设某人A创建了一个帐户并登录。因此,现在,当人B打开网站时,他已经登录了人A的帐户。

exports.sendSignUpRequest =函数(请求,res){

/test/path/node/Id

};

exports.sendLoginRequest =函数(请求,res){

const email = request.body.username;
const password = request.body.password;


firebase.auth().createUserWithEmailAndPassword(email, password).then(function(user) {
    var user = firebase.auth().currentUser;
    console.log(user.uid);
    const dataBaseRef = firebase.database().ref('users/'+user.uid+'/credentials');
    dataBaseRef.set({
        email : email,
    });
    res.redirect('/');
}, function(error) {
    console.log("error has happened because of : "+ error.message);
    res.render('signup', {error: error.message});
});

};

exports.home =函数(要求,要求){

const email = request.body.username;
const password = request.body.password;
firebase.auth().signInWithEmailAndPassword(email, password)
    .then(function(firebaseUser) {
        console.log(firebaseUser.user.email);            
        res.redirect('/');            
    }).catch(function(error) {
    res.render('login', {error: error.message, success:''});
});

};

// FIREBASE数据库的规则 {   / *访问https://firebase.google.com/docs/database/security,以了解有关安全规则的更多信息。 * /     “规则”:{       “ .read”:是的,       “ .write”:是的,         “产品”:{         “ .indexOn”:[“ featuredProduct”,“ type”,“ productId”],         “ .write”:“ auth.token.admin == true”         },       “ customerDiary”:{         “ .write”:“ auth.token.admin == true”       },       “用户”:{         “ $ user_id”:{             “ .read”:“ $ user_id === auth.uid”,             “ .write”:“ $ user_id === auth.uid”,           “订单”:{           “ .indexOn”:[“ orderStatus”]           }
        }
        }   } }

0 个答案:

没有答案