mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup. Moving closer to new release.
This commit is contained in:
@@ -37,16 +37,15 @@ class Authenticate
|
||||
if (Auth::guard($guard)->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
} else {
|
||||
if (intval(Auth::user()->blocked) === 1) {
|
||||
Auth::guard($guard)->logout();
|
||||
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
if (intval(Auth::user()->blocked) === 1) {
|
||||
Auth::guard($guard)->logout();
|
||||
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@@ -40,17 +40,16 @@ class AuthenticateTwoFactor
|
||||
if (Auth::guard($guard)->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
} else {
|
||||
|
||||
if (intval(Auth::user()->blocked) === 1) {
|
||||
Auth::guard($guard)->logout();
|
||||
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
if (intval(Auth::user()->blocked) === 1) {
|
||||
Auth::guard($guard)->logout();
|
||||
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', false)->data;
|
||||
$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
|
||||
|
@@ -38,15 +38,14 @@ class IsAdmin
|
||||
if (Auth::guard($guard)->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
} else {
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
if (!$user->hasRole('owner')) {
|
||||
return redirect(route('home'));
|
||||
}
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
if (!$user->hasRole('owner')) {
|
||||
return redirect(route('home'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@@ -38,21 +38,20 @@ class IsConfirmed
|
||||
if (Auth::guard($guard)->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
} else {
|
||||
// must the user be confirmed in the first place?
|
||||
$confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
|
||||
// user must be logged in, then continue:
|
||||
$isConfirmed = Preferences::get('user_confirmed', false)->data;
|
||||
|
||||
if ($isConfirmed === false && $confirmAccount === true) {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
// must the user be confirmed in the first place?
|
||||
$confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
|
||||
// user must be logged in, then continue:
|
||||
$isConfirmed = Preferences::get('user_confirmed', false)->data;
|
||||
|
||||
// user account is not confirmed, redirect to
|
||||
// confirmation page:
|
||||
return redirect(route('confirmation_error'));
|
||||
}
|
||||
if ($isConfirmed === false && $confirmAccount === true) {
|
||||
|
||||
// user account is not confirmed, redirect to
|
||||
// confirmation page:
|
||||
return redirect(route('confirmation_error'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@@ -38,18 +38,17 @@ class IsNotConfirmed
|
||||
if (Auth::guard($guard)->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
} else {
|
||||
// must the user be confirmed in the first place?
|
||||
$confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
|
||||
// user must be logged in, then continue:
|
||||
$isConfirmed = Preferences::get('user_confirmed', false)->data;
|
||||
if ($isConfirmed || $confirmAccount === false) {
|
||||
// user account is confirmed, simply send them home.
|
||||
return redirect(route('home'));
|
||||
}
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
// must the user be confirmed in the first place?
|
||||
$confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
|
||||
// user must be logged in, then continue:
|
||||
$isConfirmed = Preferences::get('user_confirmed', false)->data;
|
||||
if ($isConfirmed || $confirmAccount === false) {
|
||||
// user account is confirmed, simply send them home.
|
||||
return redirect(route('home'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@@ -77,16 +77,13 @@ class Range
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$journal = $repository->first();
|
||||
$first = Carbon::now()->startOfYear();
|
||||
|
||||
if (!is_null($journal->id)) {
|
||||
Session::put('first', $journal->date);
|
||||
} else {
|
||||
Session::put('first', Carbon::now()->startOfYear());
|
||||
$first = $journal->date;
|
||||
}
|
||||
Session::put('first', $first);
|
||||
}
|
||||
|
||||
// check "sum of everything".
|
||||
|
||||
|
||||
$current = Carbon::now()->formatLocalized('%B %Y');
|
||||
$next = Carbon::now()->endOfMonth()->addDay()->formatLocalized('%B %Y');
|
||||
$prev = Carbon::now()->startOfMonth()->subDay()->formatLocalized('%B %Y');
|
||||
|
Reference in New Issue
Block a user