- genRandomString(length)
generates random string of characters i.e salt
- createHash(password, salt)
hash password with sha512.
- modelActivate(parameters) ⇒
Promise.<string> Activates the model with the activationToken and returns the jwt.
- modelRequestResetPassword(parameters) ⇒
Promise.<string> Will update the reset token and send an email. If the user was found, will return passwordResetToken
- modelRequestUpdatePassword(parameters) ⇒
Promise.<string> Will update the reset token and send an email. If the user was found, will return the mail
- modelResendActivation(parameters) ⇒
Promise.<string> Request the activation token.
- modelSignIn(parameters) ⇒
Promise.<string> Signs in the model and sends back the jwt if the account is activated. Will also make the email lowercase before trying to find the document.
- modelSignUp(parameters) ⇒
Promise.<{activationToken: string, _id: string}> Creates a new document based on the supplied model the email and password. Will return the new _id
- modelVerify(parameters) ⇒
JwtPayload|null Verifies the token
generates random string of characters i.e salt
Kind: global function
| Param | Type | Description |
|---|---|---|
| length | number |
Length of the random string. |
hash password with sha512.
Kind: global function
| Param | Type | Description |
|---|---|---|
| password | string |
List of required fields. |
| salt | string |
Data to be validated. |
Gives us salt of length 16
Kind: inner constant of createHash
Activates the model with the activationToken and returns the jwt.
Kind: global function
Returns: Promise.<string> -
the jwt for the authentication
| Param | Type | Description |
|---|---|---|
| parameters | Object |
function parameters |
| parameters.Model | mongoose.Model |
mongodb model |
| parameters.variables.activationToken | string |
the activation token for which model we want to activate the account |
| parameters.onCompleted | function |
callback on completed. Returns the token. |
Will update the reset token and send an email. If the user was found, will return passwordResetToken
Kind: global function
Returns: Promise.<string> -
returns the reset token
| Param | Type | Description |
|---|---|---|
| parameters | Object |
function parameters |
| parameters.Model | mongoose.Model |
mongodb model |
| parameters.variables.email | string |
the email for which we want to reset the password |
| parameters.onCompleted | function |
callback on completed. Returns the passwordResetToken |
Will update the reset token and send an email. If the user was found, will return the mail
Kind: global function
Returns: Promise.<string> -
the found email for which we want to resend the activation
| Param | Type | Description |
|---|---|---|
| parameters | Object |
function parameters |
| parameters.Model | mongoose.Model |
mongodb model |
| parameters.variables.email | string |
the email for which we want to resend the activation |
| parameters.variables.password | string |
the new password |
| parameters.variables.passwordResetToken | string |
the passwordResetToken |
| parameters.onCompleted | function |
callback on completed. Returns the e-mail. |
Request the activation token.
Kind: global function
Returns: Promise.<string> -
the found email for which we want to resend the activation
| Param | Type | Description |
|---|---|---|
| parameters | Object |
function parameters |
| parameters.Model | mongoose.Model |
mongodb model |
| parameters.variables.email | string |
the email for which we want to resend the activation |
| parameters.onCompleted | function |
callback on completed. Returns the activationToken. |
Signs in the model and sends back the jwt if the account is activated. Will also make the email lowercase before trying to find the document.
Kind: global function
Returns: Promise.<string> -
the jwt for the authentication
| Param | Type | Description |
|---|---|---|
| parameters | Object |
function parameters |
| parameters.Model | mongoose.Model |
mongodb model |
| parameters.variables.email | string |
the email |
| parameters.variables.password | string |
the password |
| parameters.onCompleted | function |
callback on completed. Returns the jwt |
Creates a new document based on the supplied model the email and password. Will return the new _id
Kind: global function
Returns: Promise.<{activationToken: string, _id: string}> -
the _id as a string
| Param | Type | Description |
|---|---|---|
| parameters | Object |
function parameters |
| parameters.Model | mongoose.Model |
mongodb model |
| parameters.variables.email | string |
the email which will be used for registration made lowercase |
| parameters.variables.password | string |
the password |
| parameters.onCompleted | function |
callback on completed. Returns the _id |
Verifies the token
Kind: global function
Returns: JwtPayload | null -
the jwt for the authentication. If verified correctly, returns {id} so for mongoose, you need to make it _id
| Param | Type | Description |
|---|---|---|
| parameters | Object |
function parameters |
| parameters.token | string |
mongodb model |