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.
Does not commit the session.
- flexmeasures.data.services.users.find_user_by_email(user_email: str, keep_in_session: bool = True) User
- flexmeasures.data.services.users.get_user_by_id_or_raise_notfound(id: str) User
Get a user, raise if not found.
- flexmeasures.data.services.users.remove_cookie_and_token_access(user: User)
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.
Does not commit the session.
- flexmeasures.data.services.users.reset_password(user: User)
Reset the password and enable the user to set a new one. Does not commit the session.
- flexmeasures.data.services.users.set_random_password(user: User)
Randomize a user’s password.
Does not commit the session.
Exceptions
- exception flexmeasures.data.services.users.InvalidFlexMeasuresUser