Moved user registration accepting to API
This commit is contained in:
parent
243f22542d
commit
48e274234e
3 changed files with 23 additions and 11 deletions
|
@ -146,6 +146,7 @@ $userValidations =
|
|||
\Chibi\Router::register(['UserController', 'flagAction'], 'POST', '/user/{name}/flag', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'banAction'], 'POST', '/user/{name}/ban', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'unbanAction'], 'POST', '/user/{name}/unban', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'acceptRegistrationAction'], 'POST', '/user/{name}/accept-registration', $userValidations);
|
||||
|
||||
foreach (['GET', 'POST'] as $method)
|
||||
{
|
||||
|
@ -154,7 +155,6 @@ foreach (['GET', 'POST'] as $method)
|
|||
\Chibi\Router::register(['UserController', 'registrationAction'], $method, '/register', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'viewAction'], $method, '/user/{name}/{tab}', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'viewAction'], $method, '/user/{name}/{tab}/{page}', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'acceptRegistrationAction'], $method, '/user/{name}/accept-registration', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'deleteAction'], $method, '/user/{name}/delete', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'settingsAction'], $method, '/user/{name}/settings', $userValidations);
|
||||
\Chibi\Router::register(['UserController', 'editAction'], $method, '/user/{name}/edit', $userValidations);
|
||||
|
|
20
src/Api/Jobs/AcceptUserRegistrationJob.php
Normal file
20
src/Api/Jobs/AcceptUserRegistrationJob.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
class AcceptUserRegistrationJob extends AbstractUserJob
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
$user->staffConfirmed = true;
|
||||
UserModel::save($user);
|
||||
|
||||
LogHelper::log('{user} confirmed {subject}\'s account', [
|
||||
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
|
||||
'subject' => TextHelper::reprUser($user)]);
|
||||
}
|
||||
|
||||
public function requiresPrivilege()
|
||||
{
|
||||
return Privilege::AcceptUserRegistration;
|
||||
}
|
||||
}
|
|
@ -38,16 +38,8 @@ class UserController
|
|||
|
||||
public function acceptRegistrationAction($name)
|
||||
{
|
||||
$user = UserModel::findByNameOrEmail($name);
|
||||
Access::assert(
|
||||
Privilege::AcceptUserRegistration);
|
||||
|
||||
if (!InputHelper::get('submit'))
|
||||
return;
|
||||
|
||||
$user->staffConfirmed = true;
|
||||
UserModel::save($user);
|
||||
LogHelper::log('{user} confirmed {subject}\'s account', ['subject' => TextHelper::reprUser($user)]);
|
||||
Api::run(new AcceptUserRegistrationJob(), [
|
||||
AcceptUserRegistrationJob::USER_NAME => $name]);
|
||||
}
|
||||
|
||||
public function deleteAction($name)
|
||||
|
|
Loading…
Reference in a new issue