flowserv.service.user.local module

Implementation of user service API methods that access and manipulate user resources as well as access tokens. This implementation is intended for an API class that provides access to the flowserv objects directly via a local database connection.

class flowserv.service.user.local.LocalUserService(manager: flowserv.model.user.UserManager, auth: flowserv.model.auth.Auth, serializer: Optional[flowserv.view.user.UserSerializer] = None)

Bases: flowserv.service.user.base.UserService

Implement methods that handle user login and logout as well as registration and activation of new users.

activate_user(user_id: str) Dict

Activate a new user with the given identifier.

Parameters

user_id (string) – Unique user name

Return type

dict

Raises

flowserv.model.base.error.UnknownUserError

list_users(query: Optional[str] = None) Dict

Get a listing of registered users. The optional query string is used to filter users whose name starts with the given string.

Parameters

query (string, default=None) – Prefix string to filter users based on their name.

Return type

dict

login_user(username: str, password: str) Dict

Get handle for user with given credentials. Raises error if the user is unknown or if invalid credentials are provided.

Parameters
  • username (string) – Unique name of registered user

  • password (string) – User password (in plain text)

Return type

dict

Raises

flowserv.model.base.error.UnknownUserError

logout_user(api_key: str) Dict

Logout given user.

Parameters

api_key (string) – API key for user that is being logged out.

Return type

dict

Raises

flowserv.error.UnauthenticatedAccessError

register_user(username: str, password: str, verify: Optional[bool] = False) Dict

Create a new user for the given username and password. Raises an error if a user with that name already exists or if the user name is ivalid (e.g., empty or too long).

Returns success object if user was registered successfully.

Parameters
  • username (string) – User email address that is used as the username

  • password (string) – Password used to authenticate the user

  • verify (bool, default=False) – Determines whether the created user is active or inactive

Return type

dict

Raises
request_password_reset(username: str) Dict

Request to reset the password for the user with the given name. The result contains a unique request identifier for the user to send along with their new password.

Parameters

username (string) – Unique user login name

Return type

dict

reset_password(request_id: str, password: str) Dict

Reset the password for the user that made the given password reset request. Raises an error if no such request exists or if the request has timed out.

Returns the serialization of the user handle.

Parameters
  • request_id (string) – Unique password reset request identifier

  • password (string) – New user password

Return type

dict

Raises
whoami_user(api_key: str) Dict

Get serialization of the given user.

Parameters

api_key (string) – API key for a logged-in user.

Return type

dict