UserFrosting API

UserController extends SimpleController

Controller class for user-related requests, including listing users, CRUD for users, etc.

Basic controller class, that imports the entire DI container for easy access to services. Your controller classes may extend this controller class.

Tags
author

Alex Weissman (https://alexanderweissman.com)

Table of Contents

$ci ContainerInterface
create() Processes the request to create a new user (from the admin controls). mixed
createPasswordReset() Processes the request to send a user a password reset email. mixed
delete() Processes the request to delete an existing user. mixed
getActivities() Returns activity history for a single user. mixed
getInfo() Returns info for a single user. mixed
getList() Returns a list of Users. mixed
getModalConfirmDelete() Renders the modal form to confirm user deletion. mixed
getModalCreate() Renders the modal form for creating a new user. mixed
getModalEdit() Renders the modal form for editing an existing user. mixed
getModalEditPassword() Renders the modal form for editing a user's password. mixed
getModalEditRoles() Renders the modal form for editing a user's roles. mixed
getPermissions() Returns a list of effective Permissions for a specified User. mixed
getRoles() Returns roles associated with a single user. mixed
pageInfo() Renders a page displaying a user's information, in read-only mode. mixed
pageList() Renders the user listing page. mixed
updateInfo() Processes the request to update an existing user's basic details (first_name, last_name, email, locale, group_id). mixed
updateField() Processes the request to update a specific field for an existing user. mixed
getUserFromParams() Get User instance from params. User|null
__construct() Constructor. mixed

Properties

Methods

create()

Processes the request to create a new user (from the admin controls).

public create( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

Processes the request from the user creation form, checking that:

  1. The username and email are not already in use;
  2. The logged-in user has the necessary permissions to update the posted field(s);
  3. The submitted data is valid. This route requires authentication.

Request type: POST

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
see
getModalCreate
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

createPasswordReset()

Processes the request to send a user a password reset email.

public createPasswordReset( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

Processes the request from the user update form, checking that:

  1. The target user's new email address, if specified, is not already in use;
  2. The logged-in user has the necessary permissions to update the posted field(s);
  3. We're not trying to disable the master account;
  4. The submitted data is valid. This route requires authentication.

Request type: POST

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

delete()

Processes the request to delete an existing user.

public delete( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

Deletes the specified user, removing any existing associations. Before doing so, checks that:

  1. You are not trying to delete the master account;
  2. You have permission to delete the target user's account. This route requires authentication (and should generally be limited to admins or the root user).

Request type: DELETE

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

throws
BadRequestException
Return values
mixed

getActivities()

Returns activity history for a single user.

public getActivities( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getInfo()

Returns info for a single user.

public getInfo( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getList()

Returns a list of Users.

public getList( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

Generates a list of users, optionally paginated, sorted and/or filtered. This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getModalConfirmDelete()

Renders the modal form to confirm user deletion.

public getModalConfirmDelete( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

throws
BadRequestException
Return values
mixed

getModalCreate()

Renders the modal form for creating a new user.

public getModalCreate( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. If the currently logged-in user has permission to modify user group membership, then the group toggle will be displayed. Otherwise, the user will be added to the default group and receive the default roles automatically.

This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getModalEdit()

Renders the modal form for editing an existing user.

public getModalEdit( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. This page requires authentication.

Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getModalEditPassword()

Renders the modal form for editing a user's password.

public getModalEditPassword( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This does NOT render a complete page. Instead, it renders the HTML for the form, which can be embedded in other pages. This page requires authentication.

Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getModalEditRoles()

Renders the modal form for editing a user's roles.

public getModalEditRoles( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This does NOT render a complete page. Instead, it renders the HTML for the form, which can be embedded in other pages. This page requires authentication.

Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getPermissions()

Returns a list of effective Permissions for a specified User.

public getPermissions( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

Generates a list of permissions, optionally paginated, sorted and/or filtered. This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

getRoles()

Returns roles associated with a single user.

public getRoles( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

pageInfo()

Renders a page displaying a user's information, in read-only mode.

public pageInfo( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This checks that the currently logged-in user has permission to view the requested user's info. It checks each field individually, showing only those that you have permission to view. This will also try to show buttons for activating, disabling/enabling, deleting, and editing the user.

This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

pageList()

Renders the user listing page.

public pageList( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

This page renders a table of users, with dropdown menus for admin actions for each user. Actions typically include: edit user details, activate user, enable/disable user, delete user.

This page requires authentication. Request type: GET

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

updateInfo()

Processes the request to update an existing user's basic details (first_name, last_name, email, locale, group_id).

public updateInfo( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

Processes the request from the user update form, checking that:

  1. The target user's new email address, if specified, is not already in use;
  2. The logged-in user has the necessary permissions to update the putted field(s);
  3. The submitted data is valid.

This route requires authentication. Request type: PUT

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

Return values
mixed

updateField()

Processes the request to update a specific field for an existing user.

public updateField( $request : ServerRequestInterface , $response : ResponseInterface , $args : string[] ) : mixed

Supports editing all user fields, including password, enabled/disabled status and verification status. Processes the request from the user update form, checking that:

  1. The logged-in user has the necessary permissions to update the putted field(s);
  2. We're not trying to disable the master account;
  3. The submitted data is valid.

This route requires authentication. Request type: PUT

Parameters
$request : ServerRequestInterface
$response : ResponseInterface
$args : string[]
Tags
throws
NotFoundException

If user is not found

throws
ForbiddenException

If user is not authozied to access page

throws
BadRequestException
Return values
mixed

getUserFromParams()

Get User instance from params.

protected getUserFromParams( $params : string[] ) : User|null
Parameters
$params : string[]
Tags
throws
BadRequestException
Return values
User|null

__construct()

Constructor.

public __construct( $ci : ContainerInterface ) : mixed
Parameters
$ci : ContainerInterface

The global container object, which holds all your services.

Return values
mixed

Search results