Hi, I have the following code for login/logout. The issue is, if I try to login within 1/2 second after logout, it successfully logs in, but then automatically logs out. But if I give it appx. 3 seconds after logout and the re-login, its fine. Is there any configuraion I am missing, or some bug in my code is doing this?
(NB: No Error in Console)
Template.tplLogin.events({
'submit .js-frm-login': function(e, i) {
e.preventDefault();
userEmail = e.target.email.value;
userPassword = e.target.password.value;
if (!userEmail || !userPassword) {
$("#helpLogin").html("User credential fields cannot be left empty");
} else {
Meteor.loginWithPassword(userEmail, userPassword, function(error) {
if (error) {
$("#helpLogin").html(error.reason);
} else {
console.log('Authentication Successful.');
}
});
}
}
});
<template name="tplLogin">
<form class='.js-frm-login'>
<input type='text' id='email' >
<input type='password' id='password' >
<span id='helpLogin'></span>
</form>
</template>
<template name="tplMasterLayout">
{{#unless currentUser}}
{{> tplLogin}}
{{else}}
<span>LOGGED IN</span>
{{/if}}
</template>