flexmeasures.data.services.users

Functions

flexmeasures.data.services.users.create_user(password: str = None, user_roles: dict[str, str] | list[dict[str, str]] | str | list[str] | None = None, check_email_deliverability: bool = True, account_name: str | None = None, **kwargs) User

Convenience wrapper to create a new User object.

It hashes the password.

In addition to the user, this function can create - new Role objects (if user roles do not already exist) - an Account object (if it does not exist yet) - a new DataSource object that corresponds to the user

Remember to commit the session after calling this function!

flexmeasures.data.services.users.delete_user(user: User)

Delete the user (and also his assets and power measurements!).

Deleting oneself is not allowed.

Remember to commit the session after calling this function!

flexmeasures.data.services.users.find_user_by_email(user_email: str, keep_in_session: bool = True) User
flexmeasures.data.services.users.get_user(id: str) User

Get a user, raise if not found.

flexmeasures.data.services.users.get_users(account_name: str | None = None, role_name: str | None = None, account_role_name: str | None = None, only_active: bool = True) list[User]

Return a list of User objects. The role_name parameter allows to filter by role. Set only_active to False if you also want non-active users.

Remove access of current cookies and auth tokens for a user. This might be useful if you feel their password, cookie or tokens are compromised. in the former case, you can also call set_random_password.

Remember to commit the session after calling this function!

flexmeasures.data.services.users.set_random_password(user: User)

Randomise a user’s password.

Remember to commit the session after calling this function!

Exceptions

exception flexmeasures.data.services.users.InvalidFlexMeasuresUser