Skip to content

0.15.3

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 18 Jan 13:08

Overview for Auth API:

Define callback for Auth state change:

client.auth.onChange(function (authData) {
	if (authData.user != null) {
		// logged in!
	} else {
		// logged out!
	}
});

Methods:

  • client.auth.getUserData()
  • client.auth.registerWithEmailAndPassword()
  • client.auth.signInWithEmailAndPassword()
  • client.auth.signInAnonymously()
  • client.auth.sendPasswordResetEmail()
  • client.auth.signOut()
  • (❌ OAuth not yet implemented) client.auth.signInWithProvider()

Example

client.auth.signInWithEmailAndPassword("endel@colyseus.io", "123456", function(err, authData) {
    if (err != null) {
      trace(err);
    } else {
      trace("TOKEN => " + authData.token);
      trace("USER => " + authData.user);
    }
})