Auth Component
MSA has it's own auth module that can be used for managing users. All users objects are stored in the
site-{site_name}-users collection.
Auth User Guide
just.auth(login, password)
Authorizes the user at the system. Returns a Promise object that will be resolved into an array with an error and an object which contains a current site name and an active session identifier.
Params: login and password of the user.
just
.auth("user@msa.com", "sdfj38D$hd")
.then(function(res) {
// your code here
})
just.auth_register(params)
Registers a new user at the system. Returns a Promise object that will be resolved into an array with an error and an object which contains an activation link and mail options that have been sent to the user email for the activation.
Params: an object with user details including mandatory fields _id and password.
just
.auth_register({_id: "new_user@msa.com", password: "mgJ8$fgG"})
.then(function(res) {
// your code here
})
The activation link already contains all necessary infogration for activating the user account. Once user procceeds with the link he is being registered at the system.
just.auth_users()
Retrieves all users of the system. Returns a Promise object that will be resolved into an array with an error and an array with users objects.
just
.auth_users()
.then(function(res) {
// your code here
})
just.auth_check()
Checks if a user is logged-in at the system. Returns a Promise object that will be resolved into an array with an error and a boolean.
just
.auth_check()
.then(function(res) {
// your code here
})
just.auth_logout()
Logout the user at the system. Returns a Promise object that will be resolved into an array with an error and a boolean.
just
.auth_logout()
.then(function(res) {
// your code here
})
just.auth_update(params)
Updates a user data. Accepts an object with user data to be updated. Returns Promise object.
just
.auth_update()
.then(function(res) {
// your code here
})
just.auth_change_password(params)
Updates a password of a user. params is an object with new_password and old_password keys. Returns Promise object.
just
.auth_change_password({ old_password: 'ksdfhf8jsd7H', new_password: 'fhs6H*Rhh$k' })
.then(function(res) {
// your code here
})
just.auth_delete(login || [login1, login2, ...])
Removes a user or a group of users from the system. Accepts a login string or an array of logins. Returns Promise object.
just
.auth_delete(["user1@msa.com", "user2@msa.com"])
.then(function(res) {
// your code here
})
Resetting Password Process
just.auth_request_reset_password(params)
Performs request for reseting password. params is an object that contains User Id. Returns Promise object.
just
.auth_request_reset_password({_id: User._id})
.then(function(res) {
// your code here
})
just.auth_reset_password(params, reset_token)
Resets password of the user. params is an object that contains new password. reset_token is a token that gets from user email link (more information about link read below). Returns Promise object.
just
.auth_reset_password({password: 'sjd84vbK&j'}, 'caerpq847bc9uerghjse4j3htaoi7ury')
.then(function(res) {
// your code here
})