mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Various code fixes
This commit is contained in:
@@ -165,7 +165,7 @@ class LoginController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
* @return RedirectResponse|Redirector|Response
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
|
@@ -121,12 +121,13 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO why redirect AND json response?
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @return RedirectResponse|JsonResponse
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(Request $request): RedirectResponse|JsonResponse
|
||||
{
|
||||
Log::debug('Going to store new budget-limit.', $request->all());
|
||||
// first search for existing one and update it if necessary.
|
||||
|
@@ -236,84 +236,6 @@ class DebugController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all possible routes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function routes(): string
|
||||
{
|
||||
$set = RouteFacade::getRoutes();
|
||||
$ignore = [
|
||||
'chart.',
|
||||
'javascript.',
|
||||
'json.',
|
||||
'report-data.',
|
||||
'popup.',
|
||||
'debugbar.',
|
||||
'attachments.download',
|
||||
'attachments.preview',
|
||||
'bills.rescan',
|
||||
'budgets.income',
|
||||
'currencies.def',
|
||||
'error',
|
||||
'flush',
|
||||
'help.show',
|
||||
'login',
|
||||
'logout',
|
||||
'password.reset',
|
||||
'profile.confirm-email-change',
|
||||
'profile.undo-email-change',
|
||||
'register',
|
||||
'report.options',
|
||||
'routes',
|
||||
'rule-groups.down',
|
||||
'rule-groups.up',
|
||||
'rules.up',
|
||||
'rules.down',
|
||||
'rules.select',
|
||||
'search.search',
|
||||
'test-flash',
|
||||
'transactions.link.delete',
|
||||
'transactions.link.switch',
|
||||
'two-factor.lost',
|
||||
'reports.options',
|
||||
'debug',
|
||||
'preferences.delete-code',
|
||||
'rules.test-triggers',
|
||||
'piggy-banks.remove-money',
|
||||
'piggy-banks.add-money',
|
||||
'accounts.reconcile.transactions',
|
||||
'accounts.reconcile.overview',
|
||||
'transactions.clone',
|
||||
'two-factor.index',
|
||||
'api.v1',
|
||||
'installer.',
|
||||
'attachments.view',
|
||||
'recurring.events',
|
||||
'recurring.suggest',
|
||||
];
|
||||
$return = ' ';
|
||||
/** @var Route $route */
|
||||
foreach ($set as $route) {
|
||||
$name = (string)$route->getName();
|
||||
if (in_array('GET', $route->methods(), true)) {
|
||||
$found = false;
|
||||
foreach ($ignore as $string) {
|
||||
if (false !== stripos($name, $string)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (false === $found) {
|
||||
$return .= 'touch '.$route->getName().'.md;';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flash all types of messages.
|
||||
*
|
||||
|
@@ -102,14 +102,14 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @return Factory|View|RedirectResponse
|
||||
* @throws IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws InvalidCharactersException
|
||||
* @throws SecretKeyTooShortException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function code(Request $request)
|
||||
public function code(Request $request): Factory|View|RedirectResponse
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
@@ -165,7 +165,7 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function confirmEmailChange(UserRepositoryInterface $repository, string $token)
|
||||
public function confirmEmailChange(UserRepositoryInterface $repository, string $token): RedirectResponse|Redirector
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
throw new FireflyException(trans('firefly.external_user_mgt_disabled'));
|
||||
@@ -186,7 +186,7 @@ class ProfileController extends Controller
|
||||
}
|
||||
$repository->unblockUser($user);
|
||||
|
||||
// return to login.
|
||||
// return to log in.
|
||||
session()->flash('success', (string)trans('firefly.login_with_new_email'));
|
||||
|
||||
return redirect(route('login'));
|
||||
@@ -199,7 +199,7 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return Application|RedirectResponse|Redirector
|
||||
*/
|
||||
public function deleteAccount(Request $request)
|
||||
public function deleteAccount(Request $request): Application|RedirectResponse|Redirector
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
@@ -218,7 +218,7 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function deleteCode(Request $request)
|
||||
public function deleteCode(Request $request): RedirectResponse|Redirector
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
@@ -247,7 +247,7 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function enable2FA(Request $request)
|
||||
public function enable2FA(Request $request): RedirectResponse|Redirector
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
@@ -279,7 +279,7 @@ class ProfileController extends Controller
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index()
|
||||
public function index(): Factory|View
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
@@ -311,9 +311,9 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Factory|View|RedirectResponse
|
||||
*/
|
||||
public function logoutOtherSessions()
|
||||
public function logoutOtherSessions(): Factory|View|RedirectResponse
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
session()->flash('info', (string)trans('firefly.external_auth_disabled'));
|
||||
@@ -327,10 +327,10 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @return Factory|View|RedirectResponse
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function newBackupCodes(Request $request)
|
||||
public function newBackupCodes(Request $request): Factory|View|RedirectResponse
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
@@ -359,9 +359,9 @@ class ProfileController extends Controller
|
||||
* @param EmailFormRequest $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
* @return Factory|RedirectResponse|Redirector
|
||||
*/
|
||||
public function postChangeEmail(EmailFormRequest $request, UserRepositoryInterface $repository)
|
||||
public function postChangeEmail(EmailFormRequest $request, UserRepositoryInterface $repository): Factory|RedirectResponse|Redirector
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
@@ -381,7 +381,7 @@ class ProfileController extends Controller
|
||||
$existing = $repository->findByEmail($newEmail);
|
||||
if (null !== $existing) {
|
||||
// force user logout.
|
||||
Auth::guard()->logout();
|
||||
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
$request->session()->invalidate();
|
||||
|
||||
session()->flash('success', (string)trans('firefly.email_changed'));
|
||||
@@ -395,7 +395,7 @@ class ProfileController extends Controller
|
||||
event(new UserChangedEmail($user, $newEmail, $oldEmail));
|
||||
|
||||
// force user logout.
|
||||
Auth::guard()->logout();
|
||||
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
$request->session()->invalidate();
|
||||
session()->flash('success', (string)trans('firefly.email_changed'));
|
||||
|
||||
@@ -407,9 +407,9 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
* @return Factory|RedirectResponse|View
|
||||
*/
|
||||
public function changeEmail(Request $request)
|
||||
public function changeEmail(Request $request): Factory|RedirectResponse|View
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
@@ -93,14 +93,14 @@ class Authenticate
|
||||
if ($this->auth->check()) {
|
||||
// do an extra check on user object.
|
||||
/** @var User $user */
|
||||
$user = $this->auth->authenticate();
|
||||
$user = $this->auth->authenticate(); // @phpstan-ignore-line (thinks function returns void)
|
||||
if (1 === (int)$user->blocked) {
|
||||
$message = (string)trans('firefly.block_account_logout');
|
||||
if ('email_changed' === $user->blocked_code) {
|
||||
$message = (string)trans('firefly.email_changed_logout');
|
||||
}
|
||||
app('session')->flash('logoutMessage', $message);
|
||||
$this->auth->logout();
|
||||
$this->auth->logout(); // @phpstan-ignore-line (thinks function is undefined)
|
||||
|
||||
throw new AuthenticationException('Blocked account.', $guards);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class Authenticate
|
||||
);
|
||||
}
|
||||
|
||||
return $this->auth->authenticate();
|
||||
return $this->auth->authenticate(); // @phpstan-ignore-line (thinks function returns void)
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user