new MongoAuth()
- Source:
Methods
getCollectionName() → {string}
The name of the collection used to store User objects inside. Defaults to DEFAULT_COLLECTION_NAME
Returns:
the collectionName
- Type
- string
getHashStrategy() → {HashStrategy}
The HashStrategy which is used by the current instance
Returns:
the defined instance of HashStrategy
- Type
- HashStrategy
getPasswordCredentialField() → {string}
Get the name of the field to be used as property for the password of credentials in the method
AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD
Returns:
the passwordCredentialField
- Type
- string
getPasswordField() → {string}
Get the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD
Returns:
the passwordField
- Type
- string
getPermissionField() → {string}
Get the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD.
Permissions are expected to be saved as JsonArray
Returns:
the permissionField
- Type
- string
getRoleField() → {string}
Get the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to
be saved as JsonArray
Returns:
the roleField
- Type
- string
getSaltField() → {string}
Get the name of the field to be used for the salt. Only used when HashStrategy#setSaltStyle is
set to
Returns:
the saltField
- Type
- string
getUsernameCredentialField() → {string}
Get the name of the field to be used as property for the username in the method
AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD
Returns:
the usernameCredentialField
- Type
- string
getUsernameField() → {string}
Get the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD
Returns:
the usernameField
- Type
- string
insertUser(username, password, roles, permissions, resultHandler)
Insert a new user into mongo in the convenient way
Parameters:
Name | Type | Description |
---|---|---|
username |
string | the username to be set |
password |
string | the passsword in clear text, will be adapted following the definitions of the defined HashStrategy |
roles |
Array.<string> | a list of roles to be set |
permissions |
Array.<string> | a list of permissions to be set |
resultHandler |
function | the ResultHandler will be provided with the id of the generated record |
setCollectionName(collectionName) → {MongoAuth}
Set the name of the collection to be used. Defaults to DEFAULT_COLLECTION_NAME
Parameters:
Name | Type | Description |
---|---|---|
collectionName |
string | the name of the collection to be used for storing and reading user data |
- Source:
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setHashStrategy(hashStrategy) → {MongoAuth}
The HashStrategy which is used by the current instance
Parameters:
Name | Type | Description |
---|---|---|
hashStrategy |
HashStrategy | the HashStrategy to be set |
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setPasswordCredentialField(fieldName) → {MongoAuth}
Set the name of the field to be used as property for the password of credentials in the method
AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | the name of the field to be used |
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setPasswordField(fieldName) → {MongoAuth}
Set the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | the name of the field to be used |
- Source:
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setPermissionField(fieldName) → {MongoAuth}
Set the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD.
Permissions are expected to be saved as JsonArray
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | the name of the field to be used |
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setRoleField(fieldName) → {MongoAuth}
Set the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to
be saved as JsonArray
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | the name of the field to be used |
- Source:
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setSaltField(fieldName) → {MongoAuth}
Set the name of the field to be used for the salt. Only used when HashStrategy#setSaltStyle is
set to
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | the name of the field to be used |
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setUsernameCredentialField(fieldName) → {MongoAuth}
Set the name of the field to be used as property for the username in the method
AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | the name of the field to be used |
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth
setUsernameField(fieldName) → {MongoAuth}
Set the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | the name of the field to be used |
- Source:
Returns:
the current instance itself for fluent calls
- Type
- MongoAuth