UserProvider
Summary
Defines a UserProvider to get and save back end users.
Constructor
UserProvider
Syntax
UserProvider
-
database
Summary
Parameters:
-
database
DatabaseThe database to interact with
Item Index
Methods
add
Syntax
add
-
users
-
[callback]
Summary
Adds users.
Parameters:
-
users
ArrayThe list of users to store with for each user:
- String name The user name
- String email The user email
- String password The user password
- String passwordValidate The user password validation
- String [id] The user id, generated if not specified
- Array [roles] The user role ids
- Boolean [locked=false] true to lock the user from edition, false otherwise
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The total amount of users inserted
- Array The list of added users
addThirdPartyUsers
Syntax
addThirdPartyUsers
-
users
-
[callback]
Summary
Adds external users.
External users are automatically locked when added.
Parameters:
-
users
ArrayThe list of users to add with for each user:
- String name The user name
- String email The user email
- String origin Id of the third party provider system
- String originId The user id in third party provider system
- String [id] The user id, generated if not specified
- Array [originGroups] The user groups in third party provider system
- Array [roles] The user role ids
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The total amount of users inserted
- Array The inserted users
createIndexes
Syntax
createIndexes
-
callback
Summary
Creates users indexes.
Parameters:
-
callback
FunctionFunction to call when it's done with :
- Error An error if something went wrong, null otherwise
getUserByCredentials
Syntax
getUserByCredentials
-
email
-
password
-
callback
Summary
Gets an internal user by its credentials.
getUserByEmail
Syntax
getUserByEmail
-
email
-
callback
Summary
Gets an internal user by its email.
remove
Syntax
remove
-
[filter]
-
[callback]
Summary
Removes users.
This will execute core hook "USERS_DELETED" after removing users with:
- Array The ids of deleted users
Parameters:
-
[filter]
ResourceFilter optionalRules to filter users to remove
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The number of removed users
updateOne
Syntax
updateOne
-
[filter]
-
data
-
[callback]
Summary
Updates an internal user.
Parameters:
-
[filter]
ResourceFilter optionalRules to filter the user to update
-
data
ObjectThe modifications to perform
-
[name]
String optionalThe user name
-
[email]
String optionalThe user email
-
[password]
String optionalThe user password. Also requires passwordValidate
-
[passwordValidate]
String optionalThe user password validation. Also requires password
-
[roles]
Array optionalThe user role ids
-
[locked]
Boolean optionaltrue to lock the user from edition, false otherwise
-
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number 1 if everything went fine
updateThirdPartyUser
Syntax
updateThirdPartyUser
-
[filter]
-
data
-
origin
-
callback
Summary
Updates an external user.
Parameters:
-
[filter]
ResourceFilter optionalRules to filter users to update
-
data
ObjectThe modifications to perform
-
origin
StringThe user origin (see openVeoApi.passport.STRATEGIES)
-
callback
FunctionThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number 1 if everything went fine