source: app/Http/Middleware/RedirectIfFirstLogin.php

Last change on this file was dfae77e, checked in by Igor Danilovski <igor_danilovski@…>, 2 years ago
  • Initial commit;
  • Property mode set to 100644
File size: 1.1 KB
Line 
1<?php
2
3namespace App\Http\Middleware;
4
5use App\Enum\UserType;
6use App\Models\Artist;
7use App\Providers\RouteServiceProvider;
8use Closure;
9use Illuminate\Http\Request;
10use Illuminate\Support\Facades\Auth;
11
12class 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.