|
@@ -7,54 +7,54 @@ use Illuminate\Contracts\Routing\ResponseFactory;
|
|
|
|
|
|
class AuthFilter {
|
|
class AuthFilter {
|
|
|
|
|
|
-
|
|
+
|
|
- * The authenticator implementation.
|
|
+ * The authenticator implementation.
|
|
- *
|
|
+ *
|
|
- * @var Authenticator
|
|
+ * @var Authenticator
|
|
- */
|
|
+ */
|
|
- protected $auth;
|
|
+ protected $auth;
|
|
|
|
|
|
-
|
|
+
|
|
- * The response factory implementation.
|
|
+ * The response factory implementation.
|
|
- *
|
|
+ *
|
|
- * @var ResponseFactory
|
|
+ * @var ResponseFactory
|
|
- */
|
|
+ */
|
|
- protected $response;
|
|
+ protected $response;
|
|
|
|
|
|
-
|
|
+
|
|
- * Create a new filter instance.
|
|
+ * Create a new filter instance.
|
|
- *
|
|
+ *
|
|
- * @param Authenticator $auth
|
|
+ * @param Authenticator $auth
|
|
- * @param ResponseFactory $response
|
|
+ * @param ResponseFactory $response
|
|
- * @return void
|
|
+ * @return void
|
|
- */
|
|
+ */
|
|
- public function __construct(Authenticator $auth,
|
|
+ public function __construct(Authenticator $auth,
|
|
- ResponseFactory $response)
|
|
+ ResponseFactory $response)
|
|
- {
|
|
+ {
|
|
- $this->auth = $auth;
|
|
+ $this->auth = $auth;
|
|
- $this->response = $response;
|
|
+ $this->response = $response;
|
|
- }
|
|
+ }
|
|
|
|
|
|
-
|
|
+
|
|
- * Run the request filter.
|
|
+ * Run the request filter.
|
|
- *
|
|
+ *
|
|
- * @param \Illuminate\Routing\Route $route
|
|
+ * @param \Illuminate\Routing\Route $route
|
|
- * @param \Illuminate\Http\Request $request
|
|
+ * @param \Illuminate\Http\Request $request
|
|
- * @return mixed
|
|
+ * @return mixed
|
|
- */
|
|
+ */
|
|
- public function filter(Route $route, Request $request)
|
|
+ public function filter(Route $route, Request $request)
|
|
- {
|
|
+ {
|
|
- if ($this->auth->guest())
|
|
+ if ($this->auth->guest())
|
|
- {
|
|
+ {
|
|
- if ($request->ajax())
|
|
+ if ($request->ajax())
|
|
- {
|
|
+ {
|
|
- return $this->response->make('Unauthorized', 401);
|
|
+ return $this->response->make('Unauthorized', 401);
|
|
- }
|
|
+ }
|
|
- else
|
|
+ else
|
|
- {
|
|
+ {
|
|
- return $this->response->redirectGuest('auth/login');
|
|
+ return $this->response->redirectGuest('auth/login');
|
|
- }
|
|
+ }
|
|
- }
|
|
+ }
|
|
- }
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|