apicrud.controllers.account
account controller
created 31-mar-2019 by richb@instantlinux.net
Classes
- class apicrud.controllers.account.AccountController
- static change_password(uid, body)
Change password
- Parameters:
body (dict) – Fields new_password, verify_password are required; either the old_password or a reset_token can be used to authorize the request.
- Returns:
dict with account_id/uid/username, http response
- Return type:
tuple
- static create(body)
Controller for POST endpoints. This method assigns a new object ID, sets the _created_ timestamp, evaluates user’s permissions, adds a default category_id if the model has this attribute, and inserts a row to the back-end database.
- Parameters:
body (dict) – resource fields as defined by openapi.yaml schema
id_prefix (str) – generated objects will be assigned a random 10- to 16-character ID; you can set a unique prefix if desired
limit_related (dict) – limits on number of related records, keyed by relationship name
- Returns:
first element is a dict with the id, second element is response code (201 on success)
- Return type:
tuple
- static get_password(uid)
Dummy get_password function is needed for react-admin’s edit workflow (a get must precede put)
- Parameters:
uid (str) – User ID
- static register(body)
Register a new account
- Parameters:
body (dict) – If forgot_password is set, send an email with reset token. Otherwise examine username, identity (email address) and name fields. Reject the new account if a duplicate identity or username already exists. Otherwise add the new account with Person and primary Contact objects. Finally send a confirmation email to the primary contact address.
- Returns:
id of account created, and http status
- Return type:
tuple