firebase Facebook和Twitter重新认证: [英] firebase facebook and twitter Re-authenticating:
问题描述
我已经在Facebook和Twitter的应用程序中正确设置了Firebase身份验证,但是我遇到了问题。
一旦用户连接,如果他决定注销并进入用不同的凭据他不能这样做。事实上,如果他试图用Facebook注销系统不会询问他的用户名和密码,但使用之前插入的凭据。
我试着与rememberMe选项,但它没有解决这个问题。
有人可以帮我吗?
我严格遵循可以在这里找到的例子: https://www.firebase.com/docs/security/simple-login-overview.html
无论如何,我修改了一下,做了一些检查。
这是我使用的代码
$ b
firebaseRef = new Firebase('https ://cicero.firebaseio.com');
authClient = new FirebaseAuthClient(firebaseRef,function(error,user){
if(error){
/ * login error * /
switch(error.code){
case'INVALID_EMAIL':
case'INVALID_PASSWORD':
EventDispatcher.trigger(login_error,invaild user or email);
break;
case'INVALID_USER' :
EventDispatcher.trigger(login_error,user does not exist。);
break;
case'UNKNOWN_ERROR':
EventDispatcher.trigger(login_error,未知错误,请联系事件管理员。);
}
} else if(user){
/ * user si logga * /
cicero_user = user;
var users = new Users();
users.firebase.on('value',function(){
if(cicero_user.provider =='password'){
var user = users.findWhere({id:cicero_user.id,type: '密码'});
cicero_user.displayName = user.get('name');
alert(cicero_user.displayName);
} else {
var social_user = users.findWhere({id:cicero_user.id,type:cicero_user.provider});
if(social_user == undefined){
var new_social_user = new User({id:cicero_user.id,name:cicero_user.displayName,type:cicero_user.provider});
users.add(new_social_user);
}
}
Ciceronotifier.on();
EventDispatcher.trigger(hide_spinner);
Backbone.history.navigate(map,{trigger:true});
},this);
} else {
/ * user si slogga * /
cicero_user = undefined;
firebaseRef.unauth(); < - 我现在已经添加了这两行,但问题似乎未解决
firebaseRef =新的Firebase('https://cicero.firebaseio.com');
Backbone.history.navigate(login,{trigger:true});
I have properly set firebase authentication in my app for Facebook and twitter but I have a problem.
Once an user is connected, if he decides to logout and enter with a different credentials he can't do it. Indeed if he tries to logout again with Facebook the system doesn't ask his username and password but uses credentials inserted before.
I tried with rememberMe option but it didn't solve the problem. Can someone help me?
I strictly followed the example that can be found here: https://www.firebase.com/docs/security/simple-login-overview.html
Any way i modified it a little bit for doing some check. Here is the code I'm using
firebaseRef = new Firebase('https://cicero.firebaseio.com');
authClient = new FirebaseAuthClient(firebaseRef, function(error, user) {
if (error) {
/*login error*/
switch(error.code) {
case 'INVALID_EMAIL':
case 'INVALID_PASSWORD':
EventDispatcher.trigger("login_error","invaild user or email");
break;
case 'INVALID_USER':
EventDispatcher.trigger("login_error","user does not exist.");
break;
case 'UNKNOWN_ERROR':
EventDispatcher.trigger("login_error","unknown error, please contact event administrator.");
}
} else if (user) {
/*user si logga*/
cicero_user = user;
var users = new Users();
users.firebase.on('value',function(){
if(cicero_user.provider == 'password'){
var user = users.findWhere({id: cicero_user.id, type:'password'});
cicero_user.displayName = user.get('name');
alert(cicero_user.displayName);
} else {
var social_user = users.findWhere({id: cicero_user.id,type: cicero_user.provider});
if(social_user == undefined){
var new_social_user = new User({id: cicero_user.id, name: cicero_user.displayName, type: cicero_user.provider});
users.add(new_social_user);
}
}
Ciceronotifier.on();
EventDispatcher.trigger("hide_spinner");
Backbone.history.navigate("map", {trigger: true});
},this);
} else {
/*user si slogga*/
cicero_user = undefined;
firebaseRef.unauth(); <-- i have added these two lines right now but the problem seems unresolved
firebaseRef = new Firebase('https://cicero.firebaseio.com');
Backbone.history.navigate("login", {trigger: true});
这篇关于firebase Facebook和Twitter重新认证:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!