# Class: MongoAuth

## vertx-auth-mongo-js/mongo_auth~ MongoAuth

#### new MongoAuth()

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 31

### Methods

#### getCollectionName() → {string}

The name of the collection used to store User objects inside. Defaults to DEFAULT_COLLECTION_NAME

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 169

##### Returns:

the collectionName

Type
  string

#### getHashStrategy() → {HashStrategy}

The HashStrategy which is used by the current instance

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 301

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 257

##### Returns:

the passwordCredentialField

Type
  string

#### getPasswordField() → {string}

Get the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 197

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 227

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 212

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 272

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 242

##### Returns:

the usernameCredentialField

Type
  string

#### getUsernameField() → {string}

Get the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 183

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 318

#### 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:
  - vertx-auth-mongo-js/mongo_auth.js, line 44

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 286

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 138

##### 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:
  - vertx-auth-mongo-js/mongo_auth.js, line 74

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 106

##### 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:
  - vertx-auth-mongo-js/mongo_auth.js, line 90

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 154

##### 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

Source:
  - vertx-auth-mongo-js/mongo_auth.js, line 122

##### 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:
  - vertx-auth-mongo-js/mongo_auth.js, line 59

##### Returns:

the current instance itself for fluent calls

Type
  MongoAuth