user.py

User profile, permissions, and login/logout functions and endpoints.

Decorators

Decorators used to e.g. assert that a user is logged in.

Helper functions

Functions to help with user-related tasks, e.g. setting all variables at login.

Requests

User-related API endpoints, including login/logout and user manament.

user.add_new_user(user_info: dict)[source]

Add a new user to the database from first oidc login.

First check if user with the same email exists. If so, add the auth_id to the user.

Parameters

user_info (dict) – Information about the user

user.add_user()[source]

Add a user.

Returns

Information about the user as json.

Return type

flask.Response

user.delete_user(identifier: str)[source]

Delete a user.

Parameters

identifier (str) – The uuid of the user to modify.

Returns

Response code.

Return type

flask.Response

user.do_login(auth_id: str)[source]

Set all relevant variables for a logged in user.

Parameters

auth_id (str) – Authentication id for the user.

Returns bool: Whether the login succeeded.

user.gen_new_api_key(identifier: str = None)[source]

Generate a new API key for the provided or current user.

Parameters

identifier (str) – The uuid of the user.

Returns

The new API key

Return type

flask.Response

user.get_current_user()[source]

Get the current user.

Returns

The current user.

Return type

dict

user.get_current_user_info()[source]

List basic information about the current user.

Returns

json structure for the user

Return type

flask.Response

user.get_permission_info()[source]

Get a list of all permission types.

user.get_user(user_uuid=None)[source]

Get information about the user.

Parameters

user_uuid (str) – The identifier (uuid) of the user.

Returns

The current user.

Return type

dict

user.get_user_actions(identifier: str)[source]

Get a list of actions (changes) by the user entry with uuid identifier.

Can be accessed by actual user and admin (USER_MANAGEMENT).

Parameters

identifier (str) – The uuid of the user.

Returns

Information about the user as json.

Return type

flask.Response

user.get_user_data(identifier: str)[source]

Get information about a user.

Parameters

identifier (str) – The uuid of the user.

Returns

Information about the user as json.

Return type

flask.Response

user.get_user_log(identifier: str)[source]

Get change logs for the user entry with uuid identifier.

Can be accessed by actual user and admin (USER_MANAGEMENT).

Parameters

identifier (str) – The uuid of the user.

Returns

Information about the user as json.

Return type

flask.Response

user.list_users()[source]

List all users.

Admin access should be required.

user.login_required(func)[source]

Confirm that the user is logged in.

Otherwise abort with status 401 Unauthorized.

user.update_current_user_info()[source]

Update the information about the current user.

Returns

Response code.

Return type

flask.Response

user.update_user_info(identifier: str)[source]

Update the information about a user.

Requires USER_MANAGEMENT.

Parameters

identifier (str) – The uuid of the user to modify.

Returns

Response code.

Return type

flask.Response