Last change
on this file was dfae77e, checked in by Igor Danilovski <igor_danilovski@…>, 2 years ago |
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Middleware;
|
---|
4 |
|
---|
5 | use App\Enum\UserType;
|
---|
6 | use App\Models\Artist;
|
---|
7 | use App\Providers\RouteServiceProvider;
|
---|
8 | use Closure;
|
---|
9 | use Illuminate\Http\Request;
|
---|
10 | use Illuminate\Support\Facades\Auth;
|
---|
11 |
|
---|
12 | class RedirectIfFirstLogin
|
---|
13 | {
|
---|
14 | /**
|
---|
15 | * Handle an incoming request.
|
---|
16 | *
|
---|
17 | * @param \Illuminate\Http\Request $request
|
---|
18 | * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
---|
19 | * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
|
---|
20 | */
|
---|
21 | public function handle(Request $request, Closure $next)
|
---|
22 | {
|
---|
23 | $role = Auth::check() ? Auth::user()->type : '';
|
---|
24 |
|
---|
25 | switch ($role) {
|
---|
26 | case UserType::ORGANIZER->value:
|
---|
27 | case UserType::ARTIST->value:
|
---|
28 | if (!Auth::user()->role->isOnboardingCompleted()) {
|
---|
29 | return redirect()->route('onboarding');
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | return $next($request);
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.