Skip to content
myfoxtail edited this page Nov 18, 2016 · 6 revisions

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

mongoSitesApi.auth(login, password)


Authorizes the user at the system. Returns Promise object.

mongoSitesApi
    .auth("user@msa.com", "sdfj38D$hd")
    .then(function(res) {
        // your code here
    })

mongoSitesApi.auth_register(params)


Registers a new user at the system. params is an object with user details and auth data. Returns Promise object.

mongoSitesApi
    .auth_register({email: "new_user@msa.com", password: "mgJ8$fgG"})
    .then(function(res) {
        // your code here
    })

mongoSitesApi.auth_users()


Retrieves all users of the system. Returns Promise object.

mongoSitesApi
    .auth_users()
    .then(function(res) {
        // your code here
    })

mongoSitesApi.auth_check()


Checks if the user is logged in the system. Returns Promise object.

mongoSitesApi
    .auth_check()
    .then(function(res) {
        // your code here
    })

mongoSitesApi.auth_logout()


Unauthorizes the user at the system. Returns Promise object.

mongoSitesApi
    .auth_logout()
    .then(function(res) {
        // your code here
    })

mongoSitesApi.auth_update(params)


Updates a user data. Accepts an object with user data to be updated. Returns Promise object.

mongoSitesApi
    .auth_update()
    .then(function(res) {
        // your code here
    })

mongoSitesApi.auth_change_password(params)


Updates a password of a user. params is an object with new_password and old_password keys. Returns Promise object.

mongoSitesApi
    .auth_change_password({ old_password: 'ksdfhf8jsd7H', new_password: 'fhs6H*Rhh$k' })
    .then(function(res) {
        // your code here
    })

mongoSitesApi.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.

mongoSitesApi
    .auth_delete(["user1@msa.com", "user2@msa.com"])
    .then(function(res) {
        // your code here
    })

Reseting Password Process

mongoSitesApi.auth_request_reset_password(params)


Performs request for reseting password. params is an object that contains User Id. Returns Promise object.

mongoSitesApi
    .auth_request_reset_password({_id: User._id})
    .then(function(res) {
        // your code here
    })

mongoSitesApi.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.

mongoSitesApi
    .auth_reset_password({password: 'sjd84vbK&j'}, 'caerpq847bc9uerghjse4j3htaoi7ury')
    .then(function(res) {
        // your code here
    })