magpie.api.management.register.register_utils

Attributes

LOGGER

Functions

handle_temporary_token(...)

Handles the operation according to the provided temporary token.

get_discoverable_groups(→ List[magpie.models.Group])

Get all existing group that are marked as publicly discoverable from the database.

get_discoverable_group_by_name(→ magpie.models.Group)

Obtains the requested discoverable group by name.

register_pending_user(...)

Registers a temporary user pending approval.

handle_user_registration_confirmation(...)

Applies the appropriate step of the user registration workflow following reception of the confirmation URL visit.

request_admin_approval(→ None)

Sends the email to the administrator to approve or refuse the Pending User registration.

handle_user_registration_admin_decision(...)

Applies the appropriate operation according to the decision the administrator took for the pending registration.

complete_user_registration(→ None)

Completes the successful user registration following any required validation steps.

Module Contents

magpie.api.management.register.register_utils.LOGGER[source]
magpie.api.management.register.register_utils.handle_temporary_token(tmp_token: magpie.models.TemporaryToken, request: pyramid.request.Request) pyramid.httpexceptions.HTTPException | pyramid.response.Response[source]

Handles the operation according to the provided temporary token.

Returns:

Basic JSON response with successful indicate of correct handling of the token by default. If overridden, can be any HTML rendered response.

magpie.api.management.register.register_utils.get_discoverable_groups(db_session: sqlalchemy.orm.session.Session) List[magpie.models.Group][source]

Get all existing group that are marked as publicly discoverable from the database.

magpie.api.management.register.register_utils.get_discoverable_group_by_name(group_name: magpie.typedefs.Str, db_session: sqlalchemy.orm.session.Session) magpie.models.Group[source]

Obtains the requested discoverable group by name.

Note

For security reason, an existing group that is NOT discoverable will return NotFound instead of Forbidden. Otherwise we give an indication to a potentially non-admin user that some group of that name exists.

Returns:

found group matched by name

Raises:

HTTPNotFound – if the group cannot be found or if matched group name is not discoverable.

magpie.api.management.register.register_utils.register_pending_user(user_name: magpie.typedefs.Str, email: magpie.typedefs.Str, password: magpie.typedefs.Str, request: pyramid.request.Request) pyramid.httpexceptions.HTTPException[source]

Registers a temporary user pending approval.

Procedure and validation workflow is similar to normal user creation by an administrator, but employs reduced fields and different target table. Some operations are also simplified as they are not required for pending user. There is also no user creation Webhook triggers as User doesn’t exist yet.

See also

See magpie.api.management.user.user_utils.create_user() for similarities and distinctions of operations between a normal User and a Pending User.

Implements steps (1) and (2) of the user registration procedure.

See also

Returns:

HTTP created with relevant details if successful.

Raises:

HTTPException – HTTP error with relevant details upon any failing condition.

magpie.api.management.register.register_utils.handle_user_registration_confirmation(tmp_token: magpie.models.TemporaryToken, request: pyramid.request.Request) pyramid.response.Response[source]

Applies the appropriate step of the user registration workflow following reception of the confirmation URL visit.

Implements steps (3A) and (3B) redirection of the user registration procedure. Generates the appropriate response that will be displayed to the Pending User that confirmed its email.

See also

  • See proc_user_registration for the procedure step details.

  • See request_admin_approval for step 3B.

  • See complete_user_registration for step 5 (from 3A).

magpie.api.management.register.register_utils.request_admin_approval(tmp_token: magpie.models.TemporaryToken, request: pyramid.request.Request) None[source]

Sends the email to the administrator to approve or refuse the Pending User registration.

Implements step (3B) of the user registration procedure.

See also

  • See proc_user_registration for the procedure step details.

magpie.api.management.register.register_utils.handle_user_registration_admin_decision(tmp_token: magpie.models.TemporaryToken, request: pyramid.request.Request) pyramid.response.Response[source]

Applies the appropriate operation according to the decision the administrator took for the pending registration.

  • approved: Moves to step (5)

  • declined: Removes the pending user request.

Generates the appropriate response that will be displayed to the administrator.

Implements step (4) of the user registration procedure.

See also

magpie.api.management.register.register_utils.complete_user_registration(tmp_token: magpie.models.TemporaryToken, approval_required: bool, request: pyramid.request.Request) None[source]

Completes the successful user registration following any required validation steps.

Generates the User from the Pending User. Then, sends configured notification emails about successful User creation.

Implements steps (5) and (6) of the user registration procedure.

See also