Start a new topic
Answered

When I logout from an account and do login with another account it logs in with the previous one

Hello Coders,

I have this problem with the logout, it doesn't work properly for me. In fact when I log out from an account and I do log in with another one it logs in with the previous one (that is supposed to be logged out). 
Here is the code of log out function :

 

logout: function () {
      $rootScope.$broadcast('auth.logout');

      return $q.resolve($kinvey.User.getActiveUser()).then(function (user) {
        if (user) {
             return user.logout();
        } 
      });
    }

 Any Help !! 


Best Answer

Braiek,

  1. Are you confirming whether user A is successfully logged out before attempting login for user B as this is an asynchronous call? I think you are trying to login user B before user A is successfully logged out. You can try printing 'user' information before and after login and logout calls.
  2. Are you getting any error while implementing this? If yes, please send a screenshot of the same.
  3. Please take a look at http://devcenter.kinvey.com/nodejs/guides/concepts#.
  4. Your Logout function code looks different than what is mentioned on http://devcenter.kinvey.com/nodejs/guides/users#logout. Can you please confirm?


Thanks,

Pranav

Kinvey

 

Hello Pranav, 

I tried the logout with the code proposed by http://devcenter.kinvey.com/nodejs/guides/users#logout , but it has the same problem.
In fact when I log in with User B and I find userA's dashboard and I reload the page The dashboard of User B appears.
Also when I reload the login page just after the log out of User A and I log in with User B everything goes well.

i don't know if this will help you resolving the problem. Otherwise I need to make the logout a synchronously process do you know how to do it ?

Thanks 
Regards
Miled

Here you find the active user details at each step 
Regards

logout.PNG
(15.5 KB)
login.PNG
(35.1 KB)
Braiek,

Looking at the screenshots, user B is getting logged in properly. This is working as expected.

Thanks,
Pranav
Answer

Hello,

Here you find the screenshots. The first I printed "$kinvey.User.getActiveUser()" for the first login. The second is for the logout from that account and the last one for the login with another account.

logout.PNG
(15.5 KB)
login.PNG
(35.1 KB)
Braiek,

Can you please print out the user variable ($kinvey.User.getActiveUser() and any other variables you are using) before log in and after logout and then relogging in with a different user? Let me know what it prints in detail.

All Kinvey calls are Asynchronous. There is no way to make them synchronous.

Thanks,
Pranav
Kinvey



 

Login or Signup to post a comment