Fixed login when mail activation is enabled
This commit is contained in:
parent
505d08bb08
commit
7784be1838
2 changed files with 19 additions and 8 deletions
|
@ -32,12 +32,14 @@ class Access
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function check(Privilege $privilege)
|
public static function check(Privilege $privilege, $user = null)
|
||||||
{
|
{
|
||||||
if (php_sapi_name() == 'cli')
|
if (php_sapi_name() == 'cli')
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if ($user === null)
|
||||||
$user = Auth::getCurrentUser();
|
$user = Auth::getCurrentUser();
|
||||||
|
|
||||||
$minAccessRank = AccessRank::Nobody;
|
$minAccessRank = AccessRank::Nobody;
|
||||||
|
|
||||||
$key = TextCaseConverter::convert($privilege->toString(),
|
$key = TextCaseConverter::convert($privilege->toString(),
|
||||||
|
@ -58,22 +60,31 @@ class Access
|
||||||
return $user->getAccessRank()->toInteger() >= $minAccessRank;
|
return $user->getAccessRank()->toInteger() >= $minAccessRank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function checkEmailConfirmation($user = null)
|
||||||
|
{
|
||||||
|
if ($user === null)
|
||||||
|
$user = Auth::getCurrentUser();
|
||||||
|
|
||||||
|
if (!$user->emailConfirmed)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static function assertAuthentication()
|
public static function assertAuthentication()
|
||||||
{
|
{
|
||||||
if (!Auth::isLoggedIn())
|
if (!Auth::isLoggedIn())
|
||||||
self::fail('Not logged in');
|
self::fail('Not logged in');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function assert(Privilege $privilege)
|
public static function assert(Privilege $privilege, $user = null)
|
||||||
{
|
{
|
||||||
if (!self::check($privilege))
|
if (!self::check($privilege, $user))
|
||||||
self::fail();
|
self::fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function assertEmailConfirmation()
|
public static function assertEmailConfirmation($user = null)
|
||||||
{
|
{
|
||||||
$user = Auth::getCurrentUser();
|
if (!self::checkEmailConfirmation($user))
|
||||||
if (!$user->emailConfirmed)
|
|
||||||
self::fail('Need e-mail address confirmation to continue');
|
self::fail('Need e-mail address confirmation to continue');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Auth
|
||||||
throw new SimpleException('You are banned');
|
throw new SimpleException('You are banned');
|
||||||
|
|
||||||
if ($config->registration->needEmailForRegistering)
|
if ($config->registration->needEmailForRegistering)
|
||||||
Access::requireEmail($user);
|
Access::assertEmailConfirmation($user);
|
||||||
|
|
||||||
if ($remember)
|
if ($remember)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue