Note that there are some explanatory texts on larger screens.

plurals
  1. POShow a loader during the user log in process
    primarykey
    data
    text
    <p>I'm using the Accounts API to manage users. My app first tries to log in a user using their credentials, and in case that results in an error, it creates a new user account using the input credentials.</p> <pre class="lang-js prettyprint-override"><code>// Log the user in Meteor.loginWithPassword(username, token, function(error) { if(error) { // create a new user account, log them in and show the page Accounts.createUser({ username: username, email: username + '@example.com', password: token, profile: {name: username} }, showThePage); } else { // show the page //showThePage(); window.location.reload(); } }); </code></pre> <p>But this code block executes only when the user was previously logged out from their browser, and if that is the case it takes 2-3 seconds for Meteor to log the user in using <code>loginWithPassword</code>. As I'm using v0.5.0, there is no <code>Meteor.loggingIn()</code>, and the only thing I have is <code>Meteor.userLoaded()</code>. Meteor, for some reason, performs the login operation twice -- once by loading a placeholder user (that has only its userId property set) and again by loading the actual user. This makes userLoaded() return <code>true</code> twice, because of which my loader image doesn't work as expected.</p> <p>Also notice that in the else block inside loginWithPassword, I'm doing a window reload. I've a function <code>showThePage()</code> which contains all the template data &amp; event binding code. That function retrieves data using the username of the logged in user. Now because when that function in else block executes there isn't a real user logged in (remember meteor takes time to log the user in), no data gets fetched.</p> <p>Is there a workaround for this problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload