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

get_user_by_session(session_token: str)dict[source]

Get the user record associated to a session token.

Parameters

session_token – Session token.

Returns

[
    {
        "user_id": 1,
        "username": "user1",
        "created_at": "2020-11-26T22:41:40.550574"
    }
]

get_users()List[Dict[str, Any]][source]

Get the list of registered users. :return:

[
    {
        "user_id": 1,
        "username": "user1",
        "created_at": "2020-11-26T22:41:40.550574"
    },
    {
        "user_id": 2,
        "username": "user2",
        "created_at": "2020-11-28T21:10:23.224813"
    }
]
update_password(username, old_password, new_password)[source]

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