platypush.plugins.user

class platypush.plugins.user.UserPlugin(**kwargs)[source]

Plugin to programmatically create and manage users and user sessions

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

authenticate_session(session_token)[source]

Authenticate a session by token and return the associated user :return: dict.

Format:

{
    "user_id": int,
    "username": str,
    "created_at": str (in ISO format)
}
authenticate_user(username, password)[source]

Authenticate a user :return: True if the provided username and password are correct, False otherwise

create_session(username, password, expires_at=None)[source]

Create a user session :return: dict:

{
    "session_token": str,
    "user_id": int,
    "created_at": str (in ISO format),
    "expires_at": str (in ISO format),
}
create_user(username, password, executing_user=None, executing_user_password=None, session_token=None, **kwargs)[source]
Create a user. This action needs to be executed by an already existing user, who needs to authenticate with
their own credentials, unless this is the first user created on the system.
Returns:dict.

Format:

{
    "user_id": int,
    "username": str,
    "created_at": str (in ISO format)
}
delete_session(session_token)[source]

Delete a user session

delete_user(username, executing_user=None, executing_user_password=None, session_token=None)[source]

Delete a user

update_password(username, old_password, new_password)[source]

Update the password of a user :return: True if the password was successfully updated, false otherwise