Fixed confirming user registration by staff
This commit is contained in:
parent
d8808df091
commit
4395087a7c
3 changed files with 46 additions and 3 deletions
|
@ -10,7 +10,7 @@ class AcceptUserRegistrationJob extends AbstractJob
|
||||||
|
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$user = $this->userRetriever->getRequiredArguments();
|
$user = $this->userRetriever->retrieve();
|
||||||
|
|
||||||
$user->setStaffConfirmed(true);
|
$user->setStaffConfirmed(true);
|
||||||
UserModel::save($user);
|
UserModel::save($user);
|
||||||
|
@ -18,6 +18,8 @@ class AcceptUserRegistrationJob extends AbstractJob
|
||||||
Logger::log('{user} confirmed {subject}\'s account', [
|
Logger::log('{user} confirmed {subject}\'s account', [
|
||||||
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
|
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
|
||||||
'subject' => TextHelper::reprUser($user)]);
|
'subject' => TextHelper::reprUser($user)]);
|
||||||
|
|
||||||
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequiredArguments()
|
public function getRequiredArguments()
|
||||||
|
|
22
tests/JobTests/AcceptUserRegistrationJobTest.php
Normal file
22
tests/JobTests/AcceptUserRegistrationJobTest.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
class AcceptUserRegistrationJobTest extends AbstractTest
|
||||||
|
{
|
||||||
|
public function testConfirming()
|
||||||
|
{
|
||||||
|
$this->grantAccess('acceptUserRegistration');
|
||||||
|
|
||||||
|
$user = $this->mockUser();
|
||||||
|
$this->assert->isFalse($user->isStaffConfirmed());
|
||||||
|
|
||||||
|
$user = $this->assert->doesNotThrow(function() use ($user)
|
||||||
|
{
|
||||||
|
return Api::run(
|
||||||
|
new AcceptUserRegistrationJob(),
|
||||||
|
[
|
||||||
|
JobArgs::ARG_USER_NAME => $user->getName(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->isTrue($user->isStaffConfirmed());
|
||||||
|
}
|
||||||
|
}
|
|
@ -78,7 +78,7 @@ class AuthTest extends AbstractTest
|
||||||
}, 'You are banned');
|
}, 'You are banned');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStaffConfirmationEnabled()
|
public function testStaffConfirmationEnabledFail()
|
||||||
{
|
{
|
||||||
getConfig()->registration->staffActivation = true;
|
getConfig()->registration->staffActivation = true;
|
||||||
getConfig()->registration->needEmailForRegistering = false;
|
getConfig()->registration->needEmailForRegistering = false;
|
||||||
|
@ -93,7 +93,24 @@ class AuthTest extends AbstractTest
|
||||||
}, 'staff hasn\'t confirmed');
|
}, 'staff hasn\'t confirmed');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStaffConfirmationDisabled()
|
public function testStaffConfirmationEnabledPass()
|
||||||
|
{
|
||||||
|
getConfig()->registration->staffActivation = true;
|
||||||
|
getConfig()->registration->needEmailForRegistering = false;
|
||||||
|
|
||||||
|
$user = $this->prepareValidUser();
|
||||||
|
$user->setStaffConfirmed(true);
|
||||||
|
UserModel::save($user);
|
||||||
|
|
||||||
|
$this->assert->doesNotThrow(function()
|
||||||
|
{
|
||||||
|
Auth::login('existing', 'bleee', false);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->assert->isTrue(Auth::isLoggedIn());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStaffConfirmationDisabledPass()
|
||||||
{
|
{
|
||||||
getConfig()->registration->staffActivation = false;
|
getConfig()->registration->staffActivation = false;
|
||||||
getConfig()->registration->needEmailForRegistering = false;
|
getConfig()->registration->needEmailForRegistering = false;
|
||||||
|
@ -106,6 +123,8 @@ class AuthTest extends AbstractTest
|
||||||
{
|
{
|
||||||
Auth::login('existing', 'bleee', false);
|
Auth::login('existing', 'bleee', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->assert->isTrue(Auth::isLoggedIn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMailConfirmationEnabledFail1()
|
public function testMailConfirmationEnabledFail1()
|
||||||
|
|
Loading…
Reference in a new issue