Hook.Auth Class
Deals with user registration/authentication
Item Index
Properties
Methods
forgotPassword
(
Promise
-
data
Send a 'forgot password' confirmation email to target user email address.
Parameters:
-
data
Object
Returns:
Promise:
Example:
client.auth.forgotPassword({
email: "edreyer@doubleleft.com",
subject: "Project name: Forgot your password?",
template: "Hi {{name}}, click here to reset your password http://custom-project.com/pass-recovery-path.html?token={{token}}"
}).then(function(data){
console.log("Email enviado!", data);
}, function(data){
console.log("User not found: ", data);
});
getToken
()
String | Null
Returns:
String | Null:
login
(
Promise
-
data
Verify if user is already registered, and log-in if succeed.
Parameters:
-
data
Object
Returns:
Promise:
Example:
client.auth.login({email: "edreyer@doubleleft.com", password: "123"}).then(function(data){
console.log("User found: ", data);
}, function(data){
console.log("User not found or password invalid.", data);
});
register
(
-
data
Register a user.
Parameters:
-
data
Object
Example:
Register with email address
client.auth.register({
email: "endel@doubleleft.com",
password: "12345",
name: "Endel Dreyer"
}).then(function(user) {
console.log("Registered user: ", user);
});
resetPassword
(
Promise
-
data
Reset user password
Parameters:
-
data
Object-
password
Object -
token
Object[optional]
-
Returns:
Promise:
Example:
Getting token automatically from query string
client.auth.resetPassword("my-new-password-123").then(function(data){
console.log("Password reseted! ", data);
}, function(data){
console.log("Error", data.error);
});
Providing a token manually
client.auth.resetPassword({token: "xxx", password: "my-new-password-123"}).then(function(data){
console.log("Password reseted! ", data);
}, function(data){
console.log("Error", data.error);
});
update
(
Promise
-
data
Update current user info.
Parameters:
-
data
Object
Returns:
Promise:
Example:
client.auth.update({ score: 100 }).then(function(data){
console.log("updated successfully: ", data);
}).otherwise(function(data){
console.log("error: ", data);
});