Define callback for Auth state change:
client.auth:on_change(function (auth_data)
if auth_data.user ~= null then
-- logged in!
else
-- logged out!
end
end);
Methods:
client.auth:get_user_data()
client.auth:register_with_email_and_password()
client.auth:sign_in_with_email_and_password()
client.auth:sign_in_anonymously()
client.auth:send_password_reset_email()
client.auth:sign_out()
- (❌ OAuth not yet implemented)
client.auth:sign_in_with_provider()
Example
client.auth.sign_in_with_email_and_password("[email protected]", "123456", function(err, auth_data)
if err ~= nil then
-- err.status
-- err.message
else
print(auth_data.token) -- token
pprint(auth_data.user) -- user data
end
end)