app.login (Email/Password) strange issue

Hi All,

I am seeing a strange issue when testing login functionality from my app. I have two users-id and I am testing the log-out and log-in as different users to make sure my app works correctly . Most of the time it is working fine but randomly it logins in as the previously logged-in user.

  1. User A logs in
  2. User A logs out
  3. User B Logs in. In Realm logs, I can see User B successfully authenticated
  4. After successful login, my app invokes Realm functions to get the data. At this point, it is getting the data of User A.
  5. I noticed that right after app.login is called, the variable app.currentUser is showing the _id of user B correctly but the email address is of user A instead of the current user which is user B.

did anyone face this issue? Not sure what I am doing wrong. Can someone advise how this can be fixed?

Trying to re-post to see if anyone can suggest. Alternatively, thinking if it could be a product bug?

Hi @KumarK75,

for us to be able to help you, we need to know which SDK you’re using and show us a little more code. Specifically, how you open the realm and how you get data out of it.

Hi @Andrea_Catalini -

Thanks a lot for looking into this and for your response. Below are the details you asked me for. Please let me know if you need any other info.

The below line in index.html

Code in .js file when user clicks on Login button

var sEmail = this.getView().byId("idUserName").getValue();
var sPassword = this.getView().byId("idPassword").getValue();
const credentials = Realm.Credentials.emailPassword(sEmail, sPassword);
app = new Realm.App(	id: <<our MDB AppID>> ,timeout: “2000”)	

//credentials has the userid and password of the currently trying to login user.
var user = app.logIn(credentials).then(function (oResponse)
var currentUserEmail =; // THIS GIVES EMAIL OF PREV USER
var userId =; // THIS IS ‘undefined’


Thanks a lot again.

Sorry I missed the src reference in index.html .*

If you are using Realm Web 0.8.0, please consider to upgrade.

Moreover, var user = app.logIn(credentials).then(function (oResponse) ... is a mixture of how to use promises. You can use app.logIn(credentials).then(function (user) ... or let user = await app.logIn(credentials).