Search code examples
meteormeteor-accounts

Execution order of onCreateUser, onLogin, validateLoginAttempt and registerLoginHandler


I am confused by the execution order of the following methods, which one got executed first and what is the correct order?

Accounts.onCreateUser
Accounts.onLogin
Accounts.validateLoginAttempt
Accounts.registerLoginHandler

Thanks


Solution

  • I guess most of you are watching super bowl now:)

    I tried to sum it up.

    Accounts.onCreateUser usually corresponds to "Sign Up" of your web page. It will create a user in your system.

    Accounts.validateLoginAttempt: as implied by its name, it happens before "OnLogin" or "OnLoginFailure". "Accounts.validateLoginAttempt" will decide when your login succeeds or fails. Then it will pass information to "OnLogin" or "OnLoginFailure".

    Accounts.validateNewUser: called before "Accounts.validateLoginAttempt".

    Accounts.registerLoginHandler: one of login handlers. It is triggered before Accounts.OnLogin.