Skip to content

Commit d533924

Browse files
committed
refactor authentication helper functions to remove redundant null checks
1 parent 2974478 commit d533924

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

app/Http/helpers.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,20 @@
88
if (! function_exists('can')) {
99
function can(string $action): bool
1010
{
11-
if (auth()->user() === null) {
12-
return false;
13-
}
14-
1511
return auth()->user()->can($action);
1612
}
1713
}
1814

1915
if (! function_exists('cannot')) {
2016
function cannot(string $action): bool
2117
{
22-
if (auth()->user() === null) {
23-
return false;
24-
}
25-
2618
return auth()->user()->cannot($action);
2719
}
2820
}
2921

3022
if (! function_exists('hasRole')) {
3123
function hasRole(string $role): bool
3224
{
33-
if (auth()->user() === null) {
34-
return false;
35-
}
36-
3725
return auth()->user()->hasRole($role);
3826
}
3927
}

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Route::get('/', Dashboard::class)->name('dashboard');
2424

2525
Route::view('developer-reference', 'developer-reference')
26-
->name('developer-reference');
26+
->name('developer-reference');
2727

2828
Route::get('2fa', [TwoFaController::class, 'index'])->name('admin.2fa');
2929
Route::post('2fa', [TwoFaController::class, 'update'])->name('admin.2fa.update');

0 commit comments

Comments
 (0)