firebase facebook and twitter Re-authenticating:

2019-09-17 19:52发布

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?

1条回答
放我归山
2楼-- · 2019-09-17 20:13

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});
查看更多
登录 后发表回答