2020-06-19 00:42:10 +02:00
< ? php
namespace App\Controller ;
use App\Controller\AppController ;
2021-03-15 22:47:13 +01:00
use Cake\ORM\TableRegistry ;
2021-10-20 22:29:23 +02:00
use Cake\Http\Exception\UnauthorizedException ;
2022-01-18 17:52:59 +01:00
use Cake\Http\Exception\MethodNotAllowedException ;
2021-10-20 22:29:23 +02:00
use Cake\Core\Configure ;
2022-02-25 00:31:19 +01:00
use Cake\Utility\Security ;
2020-06-19 00:42:10 +02:00
class UsersController extends AppController
{
2021-11-24 01:32:05 +01:00
public $filterFields = [ 'Individuals.uuid' , 'username' , 'Individuals.email' , 'Individuals.first_name' , 'Individuals.last_name' , 'Organisations.name' ];
2021-09-10 11:55:54 +02:00
public $quickFilterFields = [ 'Individuals.uuid' , [ 'username' => true ], [ 'Individuals.first_name' => true ], [ 'Individuals.last_name' => true ], 'Individuals.email' ];
2021-11-24 01:32:05 +01:00
public $containFields = [ 'Individuals' , 'Roles' , 'UserSettings' , 'Organisations' ];
2021-09-10 11:55:54 +02:00
2020-06-19 00:42:10 +02:00
public function index ()
{
2021-11-24 01:32:05 +01:00
$currentUser = $this -> ACL -> getUser ();
$conditions = [];
if ( empty ( $currentUser [ 'role' ][ 'perm_admin' ])) {
$conditions [ 'organisation_id' ] = $currentUser [ 'organisation_id' ];
}
2020-06-19 00:42:10 +02:00
$this -> CRUD -> index ([
2021-09-10 11:55:54 +02:00
'contain' => $this -> containFields ,
'filters' => $this -> filterFields ,
'quickFilters' => $this -> quickFilterFields ,
2021-11-24 01:32:05 +01:00
'conditions' => $conditions
2020-06-19 00:42:10 +02:00
]);
2021-06-29 16:15:05 +02:00
$responsePayload = $this -> CRUD -> getResponsePayload ();
if ( ! empty ( $responsePayload )) {
return $responsePayload ;
2020-06-19 00:42:10 +02:00
}
2022-01-25 11:34:22 +01:00
$this -> set (
'validRoles' ,
$this -> Users -> Roles -> find ( 'list' ) -> select ([ 'id' , 'name' ]) -> order ([ 'name' => 'asc' ]) -> where ([ 'perm_admin' => 0 ]) -> all () -> toArray ()
);
2020-06-19 00:42:10 +02:00
$this -> set ( 'metaGroup' , $this -> isAdmin ? 'Administration' : 'Cerebrate' );
}
public function add ()
{
2021-11-24 01:32:05 +01:00
$currentUser = $this -> ACL -> getUser ();
2022-01-25 11:34:22 +01:00
$validRoles = [];
2022-02-24 13:45:10 +01:00
$individuals_params = [
'sort' => [ 'email' => 'asc' ]
];
2022-02-25 00:31:19 +01:00
$individual_ids = [];
2022-01-25 11:34:22 +01:00
if ( ! $currentUser [ 'role' ][ 'perm_admin' ]) {
2022-02-25 10:20:25 +01:00
$validRoles = $this -> Users -> Roles -> find ( 'list' ) -> select ([ 'id' , 'name' ]) -> order ([ 'name' => 'asc' ]) -> where ([ 'perm_admin' => 0 , 'perm_org_admin' => 0 ]) -> all () -> toArray ();
2022-02-24 13:45:10 +01:00
$individual_ids = $this -> Users -> Individuals -> find ( 'aligned' , [ 'organisation_id' => $currentUser [ 'organisation_id' ]]) -> all () -> extract ( 'id' ) -> toArray ();
if ( empty ( $individual_ids )) {
$individual_ids = [ - 1 ];
}
$individuals_params [ 'conditions' ] = [ 'id IN' => $individual_ids ];
2022-01-25 15:58:31 +01:00
} else {
2022-01-25 11:34:22 +01:00
$validRoles = $this -> Users -> Roles -> find ( 'list' ) -> order ([ 'name' => 'asc' ]) -> all () -> toArray ();
}
2022-01-27 21:54:59 +01:00
$defaultRole = $this -> Users -> Roles -> find () -> select ([ 'id' ]) -> first () -> toArray ();
2022-02-24 13:45:10 +01:00
$individuals = $this -> Users -> Individuals -> find ( 'list' , $individuals_params ) -> toArray ();
2021-10-01 13:19:26 +02:00
$this -> CRUD -> add ([
2022-02-25 00:31:19 +01:00
'beforeMarshal' => function ( $data ) {
if ( empty ( $data [ 'password' ])) {
$data [ 'password' ] = Security :: randomString ( 20 );
}
return $data ;
},
2022-02-24 13:45:10 +01:00
'beforeSave' => function ( $data ) use ( $currentUser , $validRoles , $defaultRole , $individual_ids ) {
2022-01-27 21:54:59 +01:00
if ( ! isset ( $data [ 'role_id' ]) && ! empty ( $defaultRole )) {
$data [ 'role_id' ] = $defaultRole [ 'id' ];
}
2021-11-24 01:32:05 +01:00
if ( ! $currentUser [ 'role' ][ 'perm_admin' ]) {
$data [ 'organisation_id' ] = $currentUser [ 'organisation_id' ];
2022-01-25 11:34:22 +01:00
if ( ! in_array ( $data [ 'role_id' ], array_keys ( $validRoles ))) {
throw new MethodNotAllowedException ( __ ( 'You do not have permission to assign that role.' ));
}
2021-11-24 01:32:05 +01:00
}
2022-02-24 13:45:10 +01:00
if (( ! isset ( $data [ 'individual_id' ]) || $data [ 'individual_id' ] === 'new' ) && ! empty ( $data [ 'individual' ])) {
$existingOrg = $this -> Users -> Organisations -> find ( 'all' ) -> where ([ 'id' => $data [ 'organisation_id' ]]) -> select ([ 'uuid' ]) -> first ();
if ( empty ( $existingOrg )) {
throw new MethodNotAllowedException ( __ ( 'No valid organisation found. Either encode the organisation separately or select a valid one.' ));
}
$data [ 'individual' ][ 'alignments' ][] = [ 'type' => 'Member' , 'organisation' => [ 'uuid' => $existingOrg [ 'uuid' ]]];
$data [ 'individual_id' ] = $this -> Users -> Individuals -> captureIndividual ( $data [ 'individual' ]);
} else if ( ! $currentUser [ 'role' ][ 'perm_admin' ] && isset ( $data [ 'individual_id' ])) {
if ( ! in_array ( $data [ 'individual_id' ], $individual_ids )) {
throw new MethodNotAllowedException ( __ ( 'The selected individual is not aligned with your organisation. Creating a user for them is not permitted.' ));
}
}
if ( empty ( $data [ 'individual_id' ])) {
throw new MethodNotAllowedException ( __ ( 'No valid individual found. Either supply it in the request or set the individual_id to a valid value.' ));
}
2022-09-18 19:26:24 +02:00
if ( Configure :: read ( 'keycloak.enabled' )) {
$existingUserForIndividual = $this -> Users -> find () -> where ([ 'individual_id' => $data [ 'individual_id' ]]) -> first ();
if ( ! empty ( $existingUserForIndividual )) {
throw new MethodNotAllowedException ( __ ( 'Invalid individual selected - when KeyCloak is enabled, only one user account may be assigned to an individual.' ));
}
}
2021-10-01 13:19:26 +02:00
$this -> Users -> enrollUserRouter ( $data );
return $data ;
}
]);
2021-01-11 12:48:58 +01:00
$responsePayload = $this -> CRUD -> getResponsePayload ();
if ( ! empty ( $responsePayload )) {
return $responsePayload ;
2020-06-19 00:42:10 +02:00
}
2021-11-24 01:32:05 +01:00
/*
$alignments = $this -> Users -> Individuals -> Alignments -> find ( 'list' , [
//'keyField' => 'id',
'valueField' => 'organisation_id' ,
'groupField' => 'individual_id'
]) -> toArray ();
$alignments = array_map ( function ( $value ) { return array_values ( $value ); }, $alignments );
*/
$org_conditions = [];
if ( empty ( $currentUser [ 'role' ][ 'perm_admin' ])) {
$org_conditions = [ 'id' => $currentUser [ 'organisation_id' ]];
}
2020-06-19 00:42:10 +02:00
$dropdownData = [
2022-01-25 11:34:22 +01:00
'role' => $validRoles ,
2022-02-24 13:45:10 +01:00
'individual' => $individuals ,
2021-11-24 01:32:05 +01:00
'organisation' => $this -> Users -> Organisations -> find ( 'list' , [
'sort' => [ 'name' => 'asc' ],
'conditions' => $org_conditions
2020-06-19 00:42:10 +02:00
])
];
$this -> set ( compact ( 'dropdownData' ));
2022-01-27 21:54:59 +01:00
$this -> set ( 'defaultRole' , $defaultRole [ 'id' ] ? ? null );
2020-06-19 00:42:10 +02:00
$this -> set ( 'metaGroup' , $this -> isAdmin ? 'Administration' : 'Cerebrate' );
}
2020-06-21 21:27:11 +02:00
public function view ( $id = false )
2020-06-19 00:42:10 +02:00
{
2022-01-26 14:57:01 +01:00
$currentUser = $this -> ACL -> getUser ();
if ( empty ( $id ) || ( empty ( $currentUser [ 'role' ][ 'perm_org_admin' ]) && empty ( $currentUser [ 'role' ][ 'perm_admin' ]))) {
2020-06-21 21:27:11 +02:00
$id = $this -> ACL -> getUser ()[ 'id' ];
}
2020-06-19 00:42:10 +02:00
$this -> CRUD -> view ( $id , [
2021-11-24 01:32:05 +01:00
'contain' => [ 'Individuals' => [ 'Alignments' => 'Organisations' ], 'Roles' , 'Organisations' ]
2020-06-19 00:42:10 +02:00
]);
2021-06-29 16:15:05 +02:00
$responsePayload = $this -> CRUD -> getResponsePayload ();
if ( ! empty ( $responsePayload )) {
return $responsePayload ;
2020-06-19 00:42:10 +02:00
}
2022-05-17 10:42:44 +02:00
$this -> set ( 'keycloakConfig' , Configure :: read ( 'keycloak' ));
2020-06-19 00:42:10 +02:00
$this -> set ( 'metaGroup' , $this -> isAdmin ? 'Administration' : 'Cerebrate' );
}
2020-06-21 21:27:11 +02:00
public function edit ( $id = false )
2020-06-19 00:42:10 +02:00
{
2021-11-24 01:32:05 +01:00
$currentUser = $this -> ACL -> getUser ();
2022-01-25 11:34:22 +01:00
$validRoles = [];
2022-05-17 04:02:06 +02:00
$individuals_params = [
'sort' => [ 'email' => 'asc' ]
];
$individual_ids = [];
2022-01-25 11:34:22 +01:00
if ( ! $currentUser [ 'role' ][ 'perm_admin' ]) {
2022-02-25 10:20:25 +01:00
$validRoles = $this -> Users -> Roles -> find ( 'list' ) -> select ([ 'id' , 'name' ]) -> order ([ 'name' => 'asc' ]) -> where ([ 'perm_admin' => 0 , 'perm_org_admin' => 0 ]) -> all () -> toArray ();
2022-05-17 04:02:06 +02:00
$individual_ids = $this -> Users -> Individuals -> find ( 'aligned' , [ 'organisation_id' => $currentUser [ 'organisation_id' ]]) -> all () -> extract ( 'id' ) -> toArray ();
if ( empty ( $individual_ids )) {
$individual_ids = [ - 1 ];
}
$individuals_params [ 'conditions' ] = [ 'id IN' => $individual_ids ];
2022-01-25 15:58:31 +01:00
} else {
$validRoles = $this -> Users -> Roles -> find ( 'list' ) -> order ([ 'name' => 'asc' ]) -> all () -> toArray ();
2022-01-25 11:34:22 +01:00
}
2022-01-17 09:19:53 +01:00
if ( empty ( $id )) {
2021-11-24 01:32:05 +01:00
$id = $currentUser [ 'id' ];
2022-01-17 09:19:53 +01:00
} else {
2022-01-18 17:52:59 +01:00
$id = intval ( $id );
2022-01-17 09:19:53 +01:00
if (( empty ( $currentUser [ 'role' ][ 'perm_org_admin' ]) && empty ( $currentUser [ 'role' ][ 'perm_admin' ]))) {
if ( $id !== $currentUser [ 'id' ]) {
throw new MethodNotAllowedException ( __ ( 'You are not authorised to edit that user.' ));
}
}
2020-06-21 21:27:11 +02:00
}
2021-11-24 01:32:05 +01:00
2020-11-05 10:17:42 +01:00
$params = [
'removeEmpty' => [
'password'
],
'fields' => [
2022-01-18 00:20:53 +01:00
'password' , 'confirm_password'
2020-06-21 21:27:11 +02:00
]
2020-11-05 10:17:42 +01:00
];
2022-03-01 14:02:26 +01:00
if ( $this -> request -> is ([ 'get' ])) {
2022-05-17 04:02:06 +02:00
$params [ 'fields' ] = array_merge ( $params [ 'fields' ], [ 'individual_id' , 'role_id' , 'disabled' ]);
if ( ! empty ( $this -> ACL -> getUser ()[ 'role' ][ 'perm_admin' ])) {
$params [ 'fields' ][] = 'organisation_id' ;
}
2022-03-01 14:02:26 +01:00
}
if ( $this -> request -> is ([ 'post' , 'put' ]) && ! empty ( $this -> ACL -> getUser ()[ 'role' ][ 'perm_admin' ])) {
2022-01-18 00:20:53 +01:00
$params [ 'fields' ][] = 'individual_id' ;
2020-11-05 10:17:42 +01:00
$params [ 'fields' ][] = 'role_id' ;
2021-11-24 01:32:05 +01:00
$params [ 'fields' ][] = 'organisation_id' ;
2022-01-18 00:20:53 +01:00
$params [ 'fields' ][] = 'disabled' ;
2022-03-01 14:02:26 +01:00
} else if ( $this -> request -> is ([ 'post' , 'put' ]) && ! empty ( $this -> ACL -> getUser ()[ 'role' ][ 'perm_org_admin' ])) {
2022-01-25 11:34:22 +01:00
$params [ 'fields' ][] = 'role_id' ;
$params [ 'fields' ][] = 'disabled' ;
if ( ! $currentUser [ 'role' ][ 'perm_admin' ]) {
$params [ 'afterFind' ] = function ( $data , & $params ) use ( $currentUser , $validRoles ) {
2022-01-26 14:57:01 +01:00
if ( ! in_array ( $data [ 'role_id' ], array_keys ( $validRoles ))) {
throw new MethodNotAllowedException ( __ ( 'You cannot edit the given privileged user.' ));
}
if ( $data [ 'organisation_id' ] !== $currentUser [ 'organisation_id' ]) {
throw new MethodNotAllowedException ( __ ( 'You cannot edit the given user.' ));
2022-01-25 11:34:22 +01:00
}
return $data ;
};
2022-02-19 01:02:49 +01:00
$params [ 'beforeSave' ] = function ( $data ) use ( $currentUser , $validRoles ) {
if ( ! in_array ( $data [ 'role_id' ], array_keys ( $validRoles ))) {
throw new MethodNotAllowedException ( __ ( 'You cannot assign the chosen role to a user.' ));
}
return $data ;
};
2022-01-25 11:34:22 +01:00
}
2020-11-05 10:17:42 +01:00
}
$this -> CRUD -> edit ( $id , $params );
2021-01-11 12:48:58 +01:00
$responsePayload = $this -> CRUD -> getResponsePayload ();
if ( ! empty ( $responsePayload )) {
return $responsePayload ;
2020-06-19 00:42:10 +02:00
}
$dropdownData = [
2022-01-25 11:34:22 +01:00
'role' => $validRoles ,
2020-06-19 00:42:10 +02:00
'individual' => $this -> Users -> Individuals -> find ( 'list' , [
'sort' => [ 'email' => 'asc' ]
2021-11-24 01:32:05 +01:00
]),
'organisation' => $this -> Users -> Organisations -> find ( 'list' , [
'sort' => [ 'name' => 'asc' ]
2020-06-19 00:42:10 +02:00
])
];
2022-05-17 04:02:06 +02:00
$org_conditions = [];
if ( empty ( $currentUser [ 'role' ][ 'perm_admin' ])) {
$org_conditions = [ 'id' => $currentUser [ 'organisation_id' ]];
}
$dropdownData = [
'role' => $validRoles ,
'individual' => $this -> Users -> Individuals -> find ( 'list' , $individuals_params ) -> toArray (),
'organisation' => $this -> Users -> Organisations -> find ( 'list' , [
'sort' => [ 'name' => 'asc' ],
'conditions' => $org_conditions
])
];
2020-06-19 00:42:10 +02:00
$this -> set ( compact ( 'dropdownData' ));
$this -> set ( 'metaGroup' , $this -> isAdmin ? 'Administration' : 'Cerebrate' );
$this -> render ( 'add' );
}
2021-01-11 12:48:58 +01:00
public function toggle ( $id , $fieldName = 'disabled' )
{
2022-01-26 16:10:33 +01:00
$params = [
'contain' => 'Roles'
];
$currentUser = $this -> ACL -> getUser ();
if ( ! $currentUser [ 'role' ][ 'perm_admin' ]) {
$params [ 'afterFind' ] = function ( $user , & $params ) use ( $currentUser ) {
if ( ! $this -> ACL -> canEditUser ( $currentUser , $user )) {
throw new MethodNotAllowedException ( __ ( 'You cannot edit the given user.' ));
}
return $user ;
};
}
$this -> CRUD -> toggle ( $id , $fieldName , $params );
2021-01-11 12:48:58 +01:00
$responsePayload = $this -> CRUD -> getResponsePayload ();
if ( ! empty ( $responsePayload )) {
return $responsePayload ;
}
}
2020-06-19 00:42:10 +02:00
public function delete ( $id )
{
2022-01-26 15:45:57 +01:00
$currentUser = $this -> ACL -> getUser ();
2022-01-25 11:34:22 +01:00
$validRoles = [];
if ( ! $currentUser [ 'role' ][ 'perm_admin' ]) {
$validRoles = $this -> Users -> Roles -> find ( 'list' ) -> order ([ 'name' => 'asc' ]) -> all () -> toArray ();
}
$params = [
'beforeSave' => function ( $data ) use ( $currentUser , $validRoles ) {
if ( ! $currentUser [ 'role' ][ 'perm_admin' ]) {
if ( $data [ 'organisation_id' ] !== $currentUser [ 'organisation_id' ]) {
throw new MethodNotAllowedException ( __ ( 'You do not have permission to remove the given user.' ));
}
if ( ! in_array ( $data [ 'role_id' ], array_keys ( $validRoles ))) {
throw new MethodNotAllowedException ( __ ( 'You do not have permission to remove the given user.' ));
}
}
return $data ;
}
];
2020-06-19 00:42:10 +02:00
$this -> CRUD -> delete ( $id );
2021-01-11 12:48:58 +01:00
$responsePayload = $this -> CRUD -> getResponsePayload ();
if ( ! empty ( $responsePayload )) {
return $responsePayload ;
2020-06-19 00:42:10 +02:00
}
$this -> set ( 'metaGroup' , $this -> isAdmin ? 'Administration' : 'Cerebrate' );
}
2020-06-21 21:27:11 +02:00
public function login ()
{
2022-09-19 00:25:15 +02:00
$blocked = false ;
if ( $this -> request -> is ( 'post' )) {
$BruteforceTable = TableRegistry :: getTableLocator () -> get ( 'Bruteforces' );
$input = $this -> request -> getData ();
$blocked = $BruteforceTable -> isBlocklisted ( $_SERVER [ 'REMOTE_ADDR' ], $input [ 'username' ]);
if ( $blocked ) {
$this -> Authentication -> logout ();
$this -> Flash -> error ( __ ( 'Too many attempts, brute force protection triggered. Wait 5 minutes before trying again.' ));
$this -> redirect ([ 'controller' => 'users' , 'action' => 'login' ]);
}
2020-06-21 21:27:11 +02:00
}
2022-09-19 00:25:15 +02:00
if ( ! $blocked ) {
$result = $this -> Authentication -> getResult ();
// If the user is logged in send them away.
$logModel = $this -> Users -> auditLogs ();
if ( $result -> isValid ()) {
$user = $logModel -> userInfo ();
$logModel -> insert ([
'request_action' => 'login' ,
'model' => 'Users' ,
'model_id' => $user [ 'id' ],
'model_title' => $user [ 'name' ],
'changed' => []
]);
$target = $this -> Authentication -> getLoginRedirect () ? ? '/instance/home' ;
return $this -> redirect ( $target );
}
if ( $this -> request -> is ( 'post' ) && ! $result -> isValid ()) {
$BruteforceTable -> insert ( $_SERVER [ 'REMOTE_ADDR' ], $input [ 'username' ]);
$logModel -> insert ([
'request_action' => 'login_fail' ,
'model' => 'Users' ,
'model_id' => 0 ,
'model_title' => 'unknown_user' ,
'changed' => []
]);
$this -> Flash -> error ( __ ( 'Invalid username or password' ));
}
2020-06-21 21:27:11 +02:00
}
$this -> viewBuilder () -> setLayout ( 'login' );
}
public function logout ()
{
$result = $this -> Authentication -> getResult ();
if ( $result -> isValid ()) {
2021-11-17 15:49:28 +01:00
$logModel = $this -> Users -> auditLogs ();
$user = $logModel -> userInfo ();
$logModel -> insert ([
'request_action' => 'logout' ,
'model' => 'Users' ,
'model_id' => $user [ 'id' ],
'model_title' => $user [ 'name' ],
2021-11-25 00:57:31 +01:00
'changed' => []
2021-11-17 15:49:28 +01:00
]);
2020-06-21 21:27:11 +02:00
$this -> Authentication -> logout ();
$this -> Flash -> success ( __ ( 'Goodbye.' ));
2022-10-25 15:08:41 +02:00
if ( Configure :: read ( 'keycloak.enabled' )) {
$this -> redirect ( $this -> Users -> keyCloaklogout ());
}
2021-04-30 23:59:53 +02:00
return $this -> redirect ( \Cake\Routing\Router :: url ( '/users/login' ));
2020-06-21 21:27:11 +02:00
}
}
2021-03-15 22:47:13 +01:00
2022-01-25 15:27:34 +01:00
public function settings ( $user_id = false )
2021-10-12 10:16:36 +02:00
{
2022-01-26 12:11:44 +01:00
$editingAnotherUser = false ;
2022-01-25 15:27:34 +01:00
$currentUser = $this -> ACL -> getUser ();
2022-01-26 12:11:44 +01:00
if ( empty ( $currentUser [ 'role' ][ 'perm_admin' ]) || $user_id == $currentUser -> id ) {
2022-01-25 15:27:34 +01:00
$user = $currentUser ;
} else {
$user = $this -> Users -> get ( $user_id , [
2022-01-26 12:11:44 +01:00
'contain' => [ 'Roles' , 'Individuals' => 'Organisations' , 'Organisations' , 'UserSettings' ]
2022-01-25 15:27:34 +01:00
]);
2022-01-26 12:11:44 +01:00
$editingAnotherUser = true ;
2022-01-25 15:27:34 +01:00
}
2022-01-26 12:11:44 +01:00
$this -> set ( 'editingAnotherUser' , $editingAnotherUser );
2022-01-25 15:27:34 +01:00
$this -> set ( 'user' , $user );
$all = $this -> Users -> UserSettings -> getSettingsFromProviderForUser ( $user -> id , true );
2021-10-18 13:28:26 +02:00
$this -> set ( 'settingsProvider' , $all [ 'settingsProvider' ]);
$this -> set ( 'settings' , $all [ 'settings' ]);
$this -> set ( 'settingsFlattened' , $all [ 'settingsFlattened' ]);
$this -> set ( 'notices' , $all [ 'notices' ]);
2021-10-12 10:16:36 +02:00
}
2021-03-15 22:47:13 +01:00
public function register ()
{
2021-10-21 13:44:49 +02:00
if ( empty ( Configure :: read ( 'security.registration.self-registration' ))) {
2021-10-20 22:29:23 +02:00
throw new UnauthorizedException ( __ ( 'User self-registration is not open.' ));
}
2022-02-19 01:34:07 +01:00
if ( ! Configure :: check ( 'security.registration.floodProtection' ) || Configure :: read ( 'security.registration.floodProtection' )) {
2022-02-07 02:03:41 +01:00
$this -> FloodProtection -> check ( 'register' );
}
2021-10-20 22:29:23 +02:00
if ( $this -> request -> is ( 'post' )) {
$data = $this -> request -> getData ();
$this -> InboxProcessors = TableRegistry :: getTableLocator () -> get ( 'InboxProcessors' );
$processor = $this -> InboxProcessors -> getProcessor ( 'User' , 'Registration' );
$data = [
'origin' => $this -> request -> clientIp (),
'comment' => '-no comment-' ,
'data' => [
'username' => $data [ 'username' ],
'email' => $data [ 'email' ],
'first_name' => $data [ 'first_name' ],
'last_name' => $data [ 'last_name' ],
'password' => $data [ 'password' ],
],
];
$processorResult = $processor -> create ( $data );
2022-02-07 02:03:41 +01:00
if ( ! empty ( Configure :: read ( 'security.registration.floodProtection' ))) {
$this -> FloodProtection -> set ( 'register' );
}
2021-10-20 22:29:23 +02:00
return $processor -> genHTTPReply ( $this , $processorResult , [ 'controller' => 'Inbox' , 'action' => 'index' ]);
}
$this -> viewBuilder () -> setLayout ( 'login' );
2021-03-15 22:47:13 +01:00
}
2020-06-19 00:42:10 +02:00
}