mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 04:21:20 +00:00
Fix code quality with rector [skip ci]
This commit is contained in:
@@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller
|
||||
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
|
||||
Log::error($message);
|
||||
|
||||
return view('errors.error', compact('message'));
|
||||
return view('errors.error', ['message' => $message]);
|
||||
}
|
||||
|
||||
// validate host header.
|
||||
@@ -138,7 +138,7 @@ class ForgotPasswordController extends Controller
|
||||
if ('web' !== config('firefly.authentication_guard')) {
|
||||
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
|
||||
|
||||
return view('errors.error', compact('message'));
|
||||
return view('errors.error', ['message' => $message]);
|
||||
}
|
||||
|
||||
// is allowed to?
|
||||
@@ -150,6 +150,6 @@ class ForgotPasswordController extends Controller
|
||||
$allowRegistration = false;
|
||||
}
|
||||
|
||||
return view('auth.passwords.email')->with(compact('allowRegistration', 'pageTitle'));
|
||||
return view('auth.passwords.email')->with(['allowRegistration' => $allowRegistration, 'pageTitle' => $pageTitle]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class LoginController extends Controller
|
||||
protected string $redirectTo = RouteServiceProvider::HOME;
|
||||
private UserRepositoryInterface $repository;
|
||||
|
||||
private string $username;
|
||||
private string $username = 'email';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
@@ -76,7 +76,6 @@ class LoginController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->username = 'email';
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->repository = app(UserRepositoryInterface::class);
|
||||
}
|
||||
@@ -90,7 +89,7 @@ class LoginController extends Controller
|
||||
{
|
||||
$username = $request->get($this->username());
|
||||
Log::channel('audit')->info(sprintf('User is trying to login using "%s"', $username));
|
||||
app('log')->debug('User is trying to login.');
|
||||
Log::debug('User is trying to login.');
|
||||
|
||||
try {
|
||||
$this->validateLogin($request);
|
||||
@@ -107,7 +106,7 @@ class LoginController extends Controller
|
||||
->onlyInput($this->username)
|
||||
;
|
||||
}
|
||||
app('log')->debug('Login data is present.');
|
||||
Log::debug('Login data is present.');
|
||||
|
||||
// Copied directly from AuthenticatesUsers, but with logging added:
|
||||
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||
@@ -115,14 +114,14 @@ class LoginController extends Controller
|
||||
// the IP address of the client making these requests into this application.
|
||||
if ($this->hasTooManyLoginAttempts($request)) {
|
||||
Log::channel('audit')->warning(sprintf('Login for user "%s" was locked out.', $request->get($this->username())));
|
||||
app('log')->error(sprintf('Login for user "%s" was locked out.', $request->get($this->username())));
|
||||
Log::error(sprintf('Login for user "%s" was locked out.', $request->get($this->username())));
|
||||
$this->fireLockoutEvent($request);
|
||||
$this->sendLockoutResponse($request);
|
||||
}
|
||||
// Copied directly from AuthenticatesUsers, but with logging added:
|
||||
if ($this->attemptLogin($request)) {
|
||||
Log::channel('audit')->info(sprintf('User "%s" has been logged in.', $request->get($this->username())));
|
||||
app('log')->debug(sprintf('Redirect after login is %s.', $this->redirectPath()));
|
||||
Log::debug(sprintf('Redirect after login is %s.', $this->redirectPath()));
|
||||
|
||||
// if you just logged in, it can't be that you have a valid 2FA cookie.
|
||||
|
||||
@@ -132,7 +131,7 @@ class LoginController extends Controller
|
||||
|
||||
return $this->sendLoginResponse($request);
|
||||
}
|
||||
app('log')->warning('Login attempt failed.');
|
||||
Log::warning('Login attempt failed.');
|
||||
$username = (string) $request->get($this->username());
|
||||
$user = $this->repository->findByEmail($username);
|
||||
if (!$user instanceof User) {
|
||||
@@ -158,10 +157,8 @@ class LoginController extends Controller
|
||||
|
||||
/**
|
||||
* Get the login username to be used by the controller.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function username()
|
||||
public function username(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
@@ -187,10 +184,8 @@ class LoginController extends Controller
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @return Redirector|RedirectResponse|Response
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
public function logout(Request $request): Redirector|RedirectResponse|Response
|
||||
{
|
||||
$authGuard = config('firefly.authentication_guard');
|
||||
$logoutUrl = config('firefly.custom_logout_url');
|
||||
@@ -227,7 +222,7 @@ class LoginController extends Controller
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showLoginForm(Request $request)
|
||||
public function showLoginForm(Request $request): Redirector|RedirectResponse|Factory|View
|
||||
{
|
||||
Log::channel('audit')->info('Show login form (1.1).');
|
||||
|
||||
@@ -263,6 +258,6 @@ class LoginController extends Controller
|
||||
}
|
||||
$usernameField = $this->username();
|
||||
|
||||
return view('auth.login', compact('allowRegistration', 'email', 'remember', 'allowReset', 'title', 'usernameField'));
|
||||
return view('auth.login', ['allowRegistration' => $allowRegistration, 'email' => $email, 'remember' => $remember, 'allowReset' => $allowReset, 'title' => $title, 'usernameField' => $usernameField]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class RegisterController extends Controller
|
||||
* @throws FireflyException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function register(Request $request)
|
||||
public function register(Request $request): Redirector|RedirectResponse
|
||||
{
|
||||
$allowRegistration = $this->allowedToRegister();
|
||||
$inviteCode = (string) $request->get('invite_code');
|
||||
@@ -146,7 +146,7 @@ class RegisterController extends Controller
|
||||
* @throws FireflyException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showInviteForm(Request $request, string $code)
|
||||
public function showInviteForm(Request $request, string $code): Factory|\Illuminate\Contracts\View\View
|
||||
{
|
||||
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
||||
$pageTitle = (string) trans('firefly.register_page_title');
|
||||
@@ -155,20 +155,20 @@ class RegisterController extends Controller
|
||||
$inviteCode = $code;
|
||||
$validCode = $repository->validateInviteCode($inviteCode);
|
||||
|
||||
if (true === $allowRegistration) {
|
||||
if ($allowRegistration) {
|
||||
$message = 'You do not need an invite code on this installation.';
|
||||
|
||||
return view('errors.error', compact('message'));
|
||||
return view('errors.error', ['message' => $message]);
|
||||
}
|
||||
if (false === $validCode) {
|
||||
$message = 'Invalid code.';
|
||||
|
||||
return view('errors.error', compact('message'));
|
||||
return view('errors.error', ['message' => $message]);
|
||||
}
|
||||
|
||||
$email = $request->old('email');
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email', 'pageTitle', 'inviteCode'));
|
||||
return view('auth.register', ['isDemoSite' => $isDemoSite, 'email' => $email, 'pageTitle' => $pageTitle, 'inviteCode' => $inviteCode]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +180,7 @@ class RegisterController extends Controller
|
||||
* @throws FireflyException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showRegistrationForm(?Request $request = null)
|
||||
public function showRegistrationForm(?Request $request = null): Factory|\Illuminate\Contracts\View\View
|
||||
{
|
||||
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
||||
$pageTitle = (string) trans('firefly.register_page_title');
|
||||
@@ -189,11 +189,11 @@ class RegisterController extends Controller
|
||||
if (false === $allowRegistration) {
|
||||
$message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.';
|
||||
|
||||
return view('errors.error', compact('message'));
|
||||
return view('errors.error', ['message' => $message]);
|
||||
}
|
||||
|
||||
$email = $request?->old('email');
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email', 'pageTitle'));
|
||||
return view('auth.register', ['isDemoSite' => $isDemoSite, 'email' => $email, 'pageTitle' => $pageTitle]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class ResetPasswordController extends Controller
|
||||
if ('web' !== config('firefly.authentication_guard')) {
|
||||
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
|
||||
|
||||
return view('errors.error', compact('message'));
|
||||
return view('errors.error', ['message' => $message]);
|
||||
}
|
||||
|
||||
$rules = [
|
||||
@@ -114,7 +114,6 @@ class ResetPasswordController extends Controller
|
||||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param null $token
|
||||
*
|
||||
* @return Factory|View
|
||||
*
|
||||
@@ -127,7 +126,7 @@ class ResetPasswordController extends Controller
|
||||
if ('web' !== config('firefly.authentication_guard')) {
|
||||
$message = sprintf('Cannot reset password when authenticating over "%s".', config('firefly.authentication_guard'));
|
||||
|
||||
return view('errors.error', compact('message'));
|
||||
return view('errors.error', ['message' => $message]);
|
||||
}
|
||||
|
||||
// is allowed to register?
|
||||
|
||||
@@ -47,26 +47,23 @@ class TwoFactorController extends Controller
|
||||
{
|
||||
/**
|
||||
* What to do if 2FA lost?
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function lostTwoFactor()
|
||||
public function lostTwoFactor(): Factory|View
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$siteOwner = config('firefly.site_owner');
|
||||
$title = (string) trans('firefly.two_factor_forgot_title');
|
||||
|
||||
return view('auth.lost-two-factor', compact('user', 'siteOwner', 'title'));
|
||||
return view('auth.lost-two-factor', ['user' => $user, 'siteOwner' => $siteOwner, 'title' => $title]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Redirector|RedirectResponse
|
||||
*
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function submitMFA(Request $request)
|
||||
public function submitMFA(Request $request): Redirector|RedirectResponse
|
||||
{
|
||||
/** @var array $mfaHistory */
|
||||
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
|
||||
@@ -214,11 +211,7 @@ class TwoFactorController extends Controller
|
||||
if (!is_array($list)) {
|
||||
$list = [];
|
||||
}
|
||||
if (in_array($mfaCode, $list, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return in_array($mfaCode, $list, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user