Klasse DUUIUserController
java.lang.Object
org.texttechnologylab.duui.api.controllers.users.DUUIUserController
A Controller for database operations related to the users collection.
- Autor:
- Cedric Borkowski
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic void
addToWorkerCount
(String id, int count) Increment or decrement (negative count) to the worker count.static String
authorizeUser
(spark.Request request, spark.Response response) Check if the user is authorized.static String
deleteLabel
(spark.Request request, spark.Response response) static String
deleteOne
(spark.Request request, spark.Response response) Delete a user from the database.static String
fetchLoginCredentials
(spark.Request request, spark.Response response) Fetch the login credentials for a user by email.static String
fetchUser
(spark.Request request, spark.Response response) Retrieve a user from the database given an id.static String
fetchUsers
(spark.Request request, spark.Response response) Retrieve multiple users from the database.filterLabelsByDriver
(String driver) static String
finishDropboxOAuthFromCode
(spark.Request request, spark.Response response) Finish the Dropbox OAuth 2.0 process given a code returned after accepting the connection with DUUI.static String
finishGoogleOAuthFromCode
(spark.Request request, spark.Response response) Finish the Google OAuth 2.0 process given a code returned after accepting the connection with DUUI.static String
getDriverLabels
(spark.Request request, spark.Response response) Get all labels from the database.static String
getDropboxAppSettings
(spark.Request request, spark.Response response) Get the Dropbox OAuth 2.0 settings.static org.bson.Document
getDropboxCredentials
(org.bson.Document user, String providerId) Retrieve the stored user credentials for dropbox (access and refresh token).static org.bson.Document
getGoogleCredentials
(org.bson.Document user, String providerId) static String
getGoogleSettings
(spark.Request request, spark.Response response) Get the Google OAuth 2.0 settings.static String
getLabels
(spark.Request request, spark.Response response) Get all labels from the database.static org.bson.Document
getMinioCredentials
(org.bson.Document user, String providerId) Retrieve the stored user credentials for minio (endpoint access and secret key).static org.bson.Document
getNextCloudCredentials
(org.bson.Document user, String providerId) Retrieve the stored user credentials for nextcloud (uri, username and password).static org.bson.Document
getUserById
(String id) Get a user by id.static org.bson.Document
getUserById
(String id, List<String> includeFields) Get a user by id.static org.bson.Document
getUserById
(org.bson.types.ObjectId id) Get a user by id.static org.bson.Document
getUserById
(org.bson.types.ObjectId id, List<String> includeFields) Get a user by id.static org.bson.Document
getUserByResetToken
(String token) Check if a user with the given password reset toekn exists.static String
insertLabel
(spark.Request request, spark.Response response) Create and insert a user into the database.static String
insertNewConnection
(spark.Request request, spark.Response response) Verify and insert new connection details.static String
insertOne
(spark.Request request, spark.Response response) Create and insert a user into the database.static org.bson.Document
matchApiKey
(String authorization) Check if a user with the given API key exists.static org.bson.Document
matchSession
(String session) Check if a user with the given session id exists.static String
recoverPassword
(spark.Request request, spark.Response response) Check if an email to reset the user password can be sent.static String
refreshAccessToken
(String refreshToken, String clientId, String clientSecret) Refresh the access token for a user given a refresh token.static String
resetPassword
(spark.Request request, spark.Response response) Reset the password of the user and store the new one.static String
resetPasswordNoToken
(spark.Request request, spark.Response response) Reset the password of the user and store the new one without.static String
updateLabel
(spark.Request request, spark.Response response) static String
updateOne
(spark.Request request, spark.Response response) Update a user given an id and a JSON object with updates.
-
Konstruktordetails
-
DUUIUserController
public DUUIUserController()
-
-
Methodendetails
-
getDropboxCredentials
Retrieve the stored user credentials for dropbox (access and refresh token).- Parameter:
user
- The user to retrieve the credentials for.- Gibt zurück:
- a
Document
containing the credentials.
-
getMinioCredentials
Retrieve the stored user credentials for minio (endpoint access and secret key).- Parameter:
user
- The user to retrieve the credentials for.- Gibt zurück:
- a
Document
containing the credentials.
-
getNextCloudCredentials
Retrieve the stored user credentials for nextcloud (uri, username and password).- Parameter:
user
- The user to retrieve the credentials for.- Gibt zurück:
- a
Document
containing the credentials.
-
getGoogleCredentials
-
getUserById
public static org.bson.Document getUserById(org.bson.types.ObjectId id) Get a user by id.- Parameter:
id
- the user id (as anObjectId
).- Gibt zurück:
- a
Document
containing the user information.
-
getUserById
Get a user by id. Fields to be included can be specified.- Parameter:
id
- the user id (as anObjectId
).includeFields
- the database fields to include.- Gibt zurück:
- a
Document
containing the user information.
-
getUserById
Get a user by id.- Parameter:
id
- the user id.- Gibt zurück:
- a
Document
containing the user information.
-
getUserById
Get a user by id. Fields to be included can be specified.- Parameter:
id
- the user id.includeFields
- the database fields to include.- Gibt zurück:
- a
Document
containing the user information.
-
matchApiKey
Check if a user with the given API key exists.- Parameter:
authorization
- the API key.- Gibt zurück:
- the user if it exists.
-
matchSession
Check if a user with the given session id exists.- Parameter:
session
- the session id from the web interface.- Gibt zurück:
- the user if it exists.
-
getUserByResetToken
Check if a user with the given password reset toekn exists.- Parameter:
token
- the password reset token set from resetting the password in the web interface.- Gibt zurück:
- the user if it exists.
-
insertOne
Create and insert a user into the database. TODO: Move request part toDUUIUsersRequestHandler
.- Gibt zurück:
- the created user.
-
insertLabel
Create and insert a user into the database. -
updateLabel
-
deleteLabel
-
getLabels
Get all labels from the database.- Gibt zurück:
- a list of labels.
-
getDriverLabels
Get all labels from the database.- Gibt zurück:
- a list of labels.
-
filterLabelsByDriver
-
deleteOne
Delete a user from the database. TODO: Move request part toDUUIUsersRequestHandler
.- Gibt zurück:
- a confirmation message.
-
recoverPassword
Check if an email to reset the user password can be sent.- Gibt zurück:
- a confirmation message.
-
resetPassword
Reset the password of the user and store the new one.- Gibt zurück:
- a confirmation message and the user email.
-
resetPasswordNoToken
Reset the password of the user and store the new one without.- Gibt zurück:
- a confirmation message and the user email.
-
fetchLoginCredentials
Fetch the login credentials for a user by email.- Gibt zurück:
- the email and password of the user for logging into the web interface.
-
updateOne
Update a user given an id and a JSON object with updates.- Gibt zurück:
- the updated user only including the updated and defaults fields.
-
insertNewConnection
Verify and insert new connection details.- Gibt zurück:
- the updated user only including the updated and defaults fields.
-
authorizeUser
Check if the user is authorized.- Gibt zurück:
- the authorized user.
-
fetchUser
Retrieve a user from the database given an id.- Gibt zurück:
- a user from the database.
-
fetchUsers
Retrieve multiple users from the database. This is only possible for admins and is used to manage roles in the web interface.- Gibt zurück:
- a list of users.
-
addToWorkerCount
Increment or decrement (negative count) to the worker count. Acts as a rate limit for threads.- Parameter:
id
- the user id.count
- the amount of workers to add or subtract.
-
finishDropboxOAuthFromCode
Finish the Dropbox OAuth 2.0 process given a code returned after accepting the connection with DUUI.- Gibt zurück:
- the user with updated dropbox credentials. See
getDropboxCredentials(Document, String)
.
-
finishGoogleOAuthFromCode
Finish the Google OAuth 2.0 process given a code returned after accepting the connection with DUUI.- Parameter:
request
- the request object.response
- the response object.- Gibt zurück:
- the user with updated google credentials. See
getGoogleCredentials(Document, String)
.
-
refreshAccessToken
public static String refreshAccessToken(String refreshToken, String clientId, String clientSecret) throws IOException Refresh the access token for a user given a refresh token.- Parameter:
refreshToken
- the refresh token.clientId
- the client id.clientSecret
- the client secret.- Gibt zurück:
- the new access token.
- Löst aus:
IOException
-
getGoogleSettings
Get the Google OAuth 2.0 settings.- Gibt zurück:
- the client id, client secret and redirect uri.
-
getDropboxAppSettings
Get the Dropbox OAuth 2.0 settings.- Gibt zurück:
- the client id, client secret and redirect uri.
-