/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     //Auth::loginUsingId(47,true);
     //dc($guard);
     //dc(Auth::user());
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax() || $request->wantsJson()) {
             return response('Unauthorized.', 401);
         } else {
             //dd('Authenticate, redirect guest login');
             //return "view";
             return redirect()->guest('login');
         }
     } elseif ($request->is('backStage/*')) {
         if (Auth::user()->isFrontEndUser()) {
             $test = 'Authenticate MIDDLEWARE: unauthorized action: ' . $request->getRequestUri() . ', ' . $request->user()->name . ' must be \'back-end user\'';
             return response()->view("errors.401", compact('test'), 401);
         }
         //dc('backStage/*');
         //dc($request->user()->isBackEndUser());
         //dc(Auth::user()->isBackEndUser());
     }
     //dc('asdf');
     //if (Auth::check())
     //dc(Auth::check());
     //	    dc($guard);
     //dc(Auth::user());
     //dd((Auth::guard($guard)->guest()));
     //	    if (Auth::user()->hasRole('mijnZD-user')){
     //		    return redirect('/dashboard');
     //return redirect()->route('sitemap.indexDashboard');
     //	    }
     //dd($request);
     return $next($request);
 }
Exemple #2
0
 /**
  * Check if user is authenticated or else display login screen.
  *
  * @param Request  $request Instance of Illuminate\Http\Request
  * @param callable $next    Instance of Closure
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!Auth::guard($this->guard)->check()) {
         return redirect()->route('admin.login', ['ref' => $request->path()]);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  * @param string|null              $guard
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect('/administrator/home');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         return response('Unauthorized.', 401);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect(($guard == 'admin' ? 'backend' : '') . '/');
     }
     return $next($request);
 }
 /**
  * Logout manager.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getLogout()
 {
     Auth::guard($this->guard)->logout();
     flash()->success(trans('messages.logout.title'), trans('messages.logout.content'));
     event('manager.logged_out');
     return redirect(route('admin.login'));
 }
 public function myAccountOrderList()
 {
     $user = Auth::guard('web')->user();
     $orders = Order::where('user_id', '=', $user->id)->get();
     $view = view('order.my-account-order-list')->with('orders', $orders);
     return $view;
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  * @param string|null              $guard
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = 'admin')
 {
     if (Auth::guard($guard)->check()) {
         return redirect('/admin');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @param Guard                     $guard
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next, Guard $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect(route('home_path'));
     }
     return $next($request);
 }
 public function getLogin(Request $request)
 {
     //Check Remember
     if (Auth::guard('admin')->viaRemember()) {
         return redirect('/');
     }
     //Check Login
     if (Auth::guard('admin')->check()) {
         return redirect('/');
     }
     //Do login
     if ($request->method() == 'POST') {
         $data = $request->only('email', 'password', 'remember');
         if ($data['remember'] == 'remember_me') {
             $this->remember = true;
         }
         $attempt = Auth::guard('admin')->attempt(['email' => $data['email'], 'password' => $data['password']], $this->remember);
         if ($attempt) {
             return redirect('/');
         } else {
             $request->session()->flash('Errors', 'Email or password is wrong');
             return redirect()->back()->withInput();
         }
     }
     return view('backend/login/index')->with(['title' => $this->title]);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (!Auth::guard($guard)->guest()) {
         return redirect(route('admin:index'));
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect()->intended('/home');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->user()->firstLogin) {
         return redirect($guard . 's/firstLogin');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect('searches');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return $this->authenticated();
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect()->route('admin.index');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     // Check for the guard and redirect accordingly
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax() || $request->wantsJson()) {
             return response('Unauthorized.', 401);
         } elseif ($guard == 'student') {
             return redirect()->guest('/students/login');
         } elseif ($guard == 'teacher') {
             return redirect()->guest('/teachers/login');
         } elseif ($guard == 'hostelStaff') {
             return redirect()->guest('/hostelStaffs/login');
         } elseif ($guard == 'libraryStaff') {
             return redirect()->guest('/libraryStaffs/login');
         } elseif ($guard == 'departmentStaff') {
             return redirect()->guest('/departmentStaffs/login');
         } elseif ($guard == 'chiefWardenStaff') {
             return redirect()->guest('/chiefWardenStaffs/login');
         } elseif ($guard == 'adminStaff') {
             return redirect()->guest('/adminStaffs/login');
         } elseif ($guard == 'admin') {
             return redirect()->guest('/admins/login');
         }
     }
     return $next($request);
 }
Exemple #18
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure                   $theNext
  * @param  string|null              $guard
  *
  * @return mixed
  * @internal param Closure $next
  */
 public function handle(Request $request, Closure $theNext, $guard = null)
 {
     if (!Auth::guard($guard)->guest()) {
         // ignore preference. set the range to be the current month:
         if (!Session::has('start') && !Session::has('end')) {
             /** @var \FireflyIII\Models\Preference $viewRange */
             $viewRange = Preferences::get('viewRange', '1M')->data;
             $start = new Carbon();
             $start = Navigation::updateStartDate($viewRange, $start);
             $end = Navigation::updateEndDate($viewRange, $start);
             Session::put('start', $start);
             Session::put('end', $end);
         }
         if (!Session::has('first')) {
             /** @var \FireflyIII\Repositories\Journal\JournalRepositoryInterface $repository */
             $repository = app('FireflyIII\\Repositories\\Journal\\JournalRepositoryInterface');
             $journal = $repository->first();
             if ($journal) {
                 Session::put('first', $journal->date);
             } else {
                 Session::put('first', Carbon::now()->startOfYear());
             }
         }
         // 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');
         View::share('currentMonthName', $current);
         View::share('previousMonthName', $prev);
         View::share('nextMonthName', $next);
     }
     return $theNext($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check() && !$request->is("register")) {
         return redirect('/');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param Closure $next
  * @param string|null $guard
  *
  * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  *
  * @fires JsonWebTokenExpired
  */
 public function handle($request, Closure $next, $guard = null)
 {
     $autheticated_user = Auth::guard($guard)->user();
     $has_valid_token = false;
     // Is the user has used "remember me" the token may not be in their session when they return
     if ($request->session()->has('jwt')) {
         $token = $request->session()->get('jwt');
         try {
             $token_user = $this->auth->authenticate($token);
             if ($token_user->id !== $autheticated_user->id) {
                 throw new JWTException('Token does not belong to the authenticated user');
             }
             $has_valid_token = true;
         } catch (TokenExpiredException $e) {
             $has_valid_token = false;
         } catch (JWTException $e) {
             if ($request->ajax()) {
                 return response('Unauthorized.', 401);
             } else {
                 return redirect()->guest('login');
             }
         }
     }
     // If there is no valid token, generate one
     if (!$has_valid_token) {
         event(new JsonWebTokenExpired($autheticated_user));
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         null;
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return $next($request);
     } else {
         if (SSO::check()) {
             try {
                 $userData = SSO::getUser();
             } catch (Exception $e) {
                 SSO::logout();
             }
             if (substr($userData->npm, 0, 2) === "15" && $userData->faculty === "ILMU KOMPUTER") {
                 $request->session()->put('sso', json_encode(SSO::getUser()));
                 if (Auth::guard($guard)->attempt(['username' => $userData->username, 'password' => ''])) {
                     return $next($request);
                 } else {
                     $id = DB::table('users')->insertGetId(['username' => $userData->username, 'fullname' => $userData->name, 'voted_threads' => "|", 'voted_replies' => "|"]);
                     // Create folder for user
                     Storage::makeDirectory('users/' . $id);
                     Auth::guard($guard)->loginUsingId($id);
                     return $next($request);
                 }
             }
             return abort(401);
         } else {
             SSO::authenticate();
         }
     }
 }
Exemple #23
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (!Auth::check() || !Auth::guard($guard)->user()->admin) {
         return redirect('/');
     }
     return $next($request);
 }
Exemple #24
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         return redirect()->guest('login');
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         $this->killDeadCookies($request);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return abort(401, "The user is already logged");
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect()->intended(route('admin.dashboard'));
     }
     return $next($request);
 }
Exemple #28
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (!Auth::guard('admin')->check()) {
         return "hata !";
     }
     //return $next($request);
 }
 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     $loginusername = $this->loginUsername();
     $this->validate($request, [$loginusername => 'required', 'password' => 'required']);
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     $possiblecolumns = $this->loginColumns();
     $templogin = $credentials[$loginusername];
     unset($credentials[$loginusername]);
     foreach ($possiblecolumns as $column) {
         $credentials[$column] = $templogin;
         if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
             return $this->handleUserWasAuthenticated($request, $throttles);
         }
         unset($credentials[$column]);
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return $this->sendFailedLoginResponse($request);
 }
Exemple #30
-1
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $role, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax() || $request->wantsJson()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('login');
         }
     }
     if (user($guard)->new && config('user.verify_email')) {
         if ($request->ajax() || $request->wantsJson()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect('verify');
         }
     }
     if (!user($guard)->active && config('user.verify_email')) {
         throw new InvalidAccountException('Account is not active.');
     }
     $roles = explode('|', $role);
     if (!user($guard)->hasRoles($roles)) {
         throw new RolesDeniedException($roles);
     }
     return $next($request);
 }