コード例 #1
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->filter('auth', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return Redirect::guest('/');
             }
         }
     });
     $router->filter('auth.basic', function () {
         return Auth::basic();
     });
     $router->filter('guest', function () {
         if (Auth::check()) {
             return Redirect::to('/');
         }
     });
     $router->filter('admin', function () {
         if (Auth::check()) {
             if (Auth::user()->email != "*****@*****.**") {
                 return Redirect::to('/');
             }
         } else {
             return Redirect::to('/');
         }
     });
     parent::boot($router);
 }
コード例 #2
0
 public function edit()
 {
     $value = Cookie::get('uid');
     if ($value != '') {
         return Redirect::guest('page/1');
     } else {
         return Redirect::guest('/login');
     }
 }
コード例 #3
0
 public function store(CreateAccountRequest $request)
 {
     //        $input = Request::all();
     $pharmacy = Pharmacy::create(["name" => $request->get('name'), "address" => $request->get('address'), "city" => $request->get('city'), "state" => $request->get('state'), "zipcode" => $request->get('zipcode'), "npi" => $request->get('npi'), "dea" => $request->get('dea'), "nabp" => $request->get('nabp'), "pic" => $request->get('pic'), "contact" => $request->get('contact'), "contact_person" => $request->get('contact_person'), "email" => $request->get('email'), "billing_address" => $request->get('billing_address'), "billing_city" => $request->get('billing_city'), "billing_state" => $request->get('billing_state'), "billing_zipcode" => $request->get('billing_zipcode'), "mailing_address" => $request->get('mailing_address'), "mailing_city" => $request->get('mailing_city'), "mailing_state" => $request->get('mailing_state'), "mailing_zipcode" => $request->get('mailing_zipcode')]);
     $pharmacists = new Pharmacist(["fname" => $request->get('name'), "mname" => $request->get('name'), "lname" => $request->get('name'), "bdate" => date('Y-m-d'), "email" => $request->get('email'), "contact" => $request->get('contact')]);
     $account = new Account(["username" => $request->get('username'), "password" => $request->get('password'), "rights" => "0"]);
     $pharmacy->pharmacists()->save($pharmacists)->account()->save($account);
     Session::flash('flash_message', 'Registration Successful!');
     return Redirect::guest('/');
 }
コード例 #4
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (config('typicms.auth_public') && !Auth::check()) {
         if ($request->ajax()) {
             return Response::make('Unauthorized', 401);
         }
         return Redirect::guest(route('login'));
     }
     return $next($request);
 }
コード例 #5
0
ファイル: AuthFilter.php プロジェクト: baa-archieve/Cachet
 /**
  * Run the auth filter.
  *
  * We're verifying that the current user is logged in to Cachet.
  *
  * @param \Illuminate\Routing\Route $route
  * @param \Illuminate\Http\Request  $request
  *
  * @return \Illuminate\Http\Response|null
  */
 public function filter(Route $route, Request $request)
 {
     if (Auth::guest()) {
         if ($request->ajax()) {
             return Response::make('Unauthorized', 401);
         } else {
             return Redirect::guest('auth/login');
         }
     }
 }
コード例 #6
0
ファイル: Auth.php プロジェクト: xhulioh25/wiki
 public function handle($request, \Closure $next)
 {
     if (!$this->credentials->check()) {
         $this->logger->info('User tried to access a page without being logged in', ['path' => $request->path()]);
         if ($request->ajax()) {
             throw new UnauthorizedHttpException('Action Requires Login');
         }
         return Redirect::guest(URL::route('account.login'))->with('error', 'You must be logged in to perform that action.');
     }
     if (!$this->credentials->hasAccess($level = $this->level())) {
         $this->logger->warning('User tried to access a page without permission', ['path' => $request->path(), 'permission' => $level]);
         throw new AccessDeniedHttpException(ucfirst($level) . ' Permissions Are Required');
     }
 }
コード例 #7
0
ファイル: TalkServiceProvider.php プロジェクト: micro/talk
 /**
  * Provide the needed filters.
  *
  * @return void
  */
 public function filters()
 {
     // authentication filter used by the system
     Route::filter('talkAuth', function () {
         if (Auth::guest() || get_class(Auth::user()) != Config::get('talk::auth.model')) {
             // redirect to login page
             return Redirect::guest(Config::get('talk::routes.base') . '/auth/login');
         }
     });
     // Make sure administrative accounts are admin only!
     Route::filter('talkAdmin', function () {
         if (Auth::guest() || Auth::user()->role != 10) {
             return 'Admin Only';
             // NO access to administration.
         }
     });
 }
コード例 #8
0
ファイル: PublicAccess.php プロジェクト: vizo/Core
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (config('typicms.auth_public') && !Auth::check()) {
         if (Request::ajax()) {
             return Response::make('Unauthorized', 401);
         }
         return Redirect::guest(route('login'));
     }
     $response = $next($request);
     // HTML cache
     if ($response instanceof View && $request->method() == 'GET' && !Auth::check() && $this->queryStringIsEmptyOrOnlyPage($request) && !config('app.debug') && config('typicms.html_cache')) {
         $directory = public_path() . '/html' . $request->getPathInfo();
         if (!File::isDirectory($directory)) {
             File::makeDirectory($directory, 0777, true);
         }
         File::put($directory . '/index' . $request->getQueryString() . '.html', $response->render());
     }
     return $response;
 }
コード例 #9
0
 /**
  * Main method, if 'successful' this method should not return anything (even true).
  *
  * @param $request
  * @return \Illuminate\Http\RedirectResponse
  * @throws Exception
  */
 public function filter($request)
 {
     // Check if user is authenticated via an auth session
     $this->session_authenticated = $this->isUserSessionAuthenticated();
     // Check if user is authenticated via an auth token
     $this->token_authenticated = $this->isUserTokenAuthenticated($request);
     // Decide if user is authenticated
     $this->user_authenticated = $this->isUserAuthenticated([$this->session_authenticated, $this->token_authenticated]);
     if ($this->user_authenticated === false) {
         // There is no way to know, for definite, which 'method' a user intended to authenticate, unless a token was
         // used, in which case it is safe to assume which method they were using.
         // In cases where a token wasn't given and the user has requested a JSON response, we assume they were trying
         // to use token authentication. Otherwise we assume they were trying to use session authentication.
         // Note: This approach maybe revised in the future.
         if ($this->token_authenticated !== false && $this->token_authenticated instanceof MissingTokenException === false || Request::wantsJson()) {
             $this->tokenAuthenticationFailure();
         }
         $this->sessionAuthenticationFailure();
         // BUG: For some reason issuing a redirect within a function other than this one doesn't do anything.
         return Redirect::guest('login');
     }
 }
コード例 #10
0
 /**
  * Filter the incoming requests.
  */
 public function filterRequests($route, $request)
 {
     if (!is_object(Sentry::getUser()) || !Sentry::getUser()->hasAccess('admin')) {
         return Redirect::guest('admin/login');
     }
 }
コード例 #11
0
 /**
  * @return bool
  */
 public function logout()
 {
     $this->admin->logout();
     return Redirect::guest('/');
 }