# Class: MongoAuth

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

#### new MongoAuth()

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

### Methods

#### authenticate(arg0, arg1)

##### Parameters:

Name | Type | Description
--- | --- | ---
`arg0` | Object |
`arg1` | function |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

##### Returns:

the current instance itself for fluent calls

Type
  MongoAuth