mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 06:31:22 +00:00
Improve code quality.
This commit is contained in:
@@ -89,9 +89,11 @@ class Authenticate
|
||||
if (empty($guards)) {
|
||||
try {
|
||||
// go for default guard:
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
if ($this->auth->check()) {
|
||||
|
||||
// do an extra check on user object.
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$user = $this->auth->authenticate();
|
||||
if (1 === (int)$user->blocked) {
|
||||
$message = (string)trans('firefly.block_account_logout');
|
||||
@@ -99,6 +101,7 @@ class Authenticate
|
||||
$message = (string)trans('firefly.email_changed_logout');
|
||||
}
|
||||
app('session')->flash('logoutMessage', $message);
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$this->auth->logout();
|
||||
|
||||
throw new AuthenticationException('Blocked account.', $guards);
|
||||
@@ -114,13 +117,14 @@ class Authenticate
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->auth->authenticate();
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
foreach ($guards as $guard) {
|
||||
if ($this->auth->guard($guard)->check()) {
|
||||
/** @noinspection PhpVoidFunctionResultUsedInspection */
|
||||
return $this->auth->shouldUse($guard);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class AuthenticateTwoFactor
|
||||
}
|
||||
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
/**
|
||||
* @param $request
|
||||
* @param Closure $next
|
||||
@@ -63,6 +64,7 @@ class AuthenticateTwoFactor
|
||||
*/
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
if ($this->auth->guest()) {
|
||||
return response()->redirectTo(route('login'));
|
||||
}
|
||||
@@ -70,6 +72,7 @@ class AuthenticateTwoFactor
|
||||
|
||||
$is2faEnabled = app('preferences')->get('twoFactorAuthEnabled', false)->data;
|
||||
$has2faSecret = null !== app('preferences')->get('twoFactorAuthSecret');
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$is2faAuthed = 'true' === $request->cookie('twoFactorAuthenticated');
|
||||
|
||||
if ($is2faEnabled && $has2faSecret && !$is2faAuthed) {
|
||||
|
||||
@@ -54,6 +54,7 @@ class Binder
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
@@ -63,7 +64,6 @@ class Binder
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
|
||||
*/
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Exceptions\IsDemoUserException;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -78,6 +78,7 @@ class Range
|
||||
private function configureView(): void
|
||||
{
|
||||
$pref = Preferences::get('language', config('firefly.default_language', 'en_US'));
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$lang = $pref->data;
|
||||
App::setLocale($lang);
|
||||
Carbon::setLocale(substr($lang, 0, 2));
|
||||
|
||||
@@ -74,6 +74,7 @@ class Sandstorm
|
||||
if (1 === $count && \strlen($userId) > 0) {
|
||||
// login as first user user.
|
||||
$user = $repository->first();
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
Auth::guard($guard)->login($user);
|
||||
View::share('SANDSTORM_ANON', false);
|
||||
|
||||
@@ -83,6 +84,7 @@ class Sandstorm
|
||||
if (1 === $count && '' === $userId) {
|
||||
// login but indicate anonymous
|
||||
$user = User::first();
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
Auth::guard($guard)->login($user);
|
||||
View::share('SANDSTORM_ANON', true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user