apicrud.auth.local_user

local_user

created 26-mar-2020 by richb@instantlinux.net monolith broken out 6-apr-2021

Classes

LocalUser([func_send])

Manage local user accounts

class apicrud.auth.local_user.LocalUser(func_send=None)

Manage local user accounts

Parameters

func_send (function) – name of function for sending message

change_password(uid, new_password, reset_token, old_password=None, verify_password=None)

Update a user’s password, applying complexity rules; must specify either the old password or a reset token

Parameters
  • uid (str) – User ID

  • new_password (str) – the new passphrase

  • reset_token (str) – a token retrieved from Confirmation.request

  • old_password (str) – the old passphrase

Returns

dict with account_id/uid/username, http response

Return type

tuple

forgot_password(identity, username, template='password_reset')

Trigger Confirmation.request; specify either the username or email address. For security, administrators are not allowed to use this feature.

Parameters
  • identity (str) – account’s primary identity, usually an email

  • username (str) – account’s username

  • template (str) – template for message (confirming new user)

Returns

the Confirmation.request dict and http response

Return type

tuple

register(identity, username, name, template='confirm_new', picture=None)

Register a new account: create related records in database and send confirmation token to new user

TODO caller still has to invoke account-create function to generate record in accounts table

Parameters
  • identity (str) – account’s primary identity, usually an email

  • username (str) – account’s username

  • name (str) – name

  • picture (url) – URL of an avatar / photo

  • template (str) – template for message (confirming new user)

Returns

the Confirmation.request dict and http response

Return type

tuple