/**
  * @api            {delete} /sessions/{sessionKey} End A Session (Logout)
  * @apiGroup       User Sessions
  * @apiDescription Deletes a user's session.
  *
  * @param UserSession $session
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy(UserSession $session)
 {
     $success = $session->delete();
     return $this->response(['success' => $success]);
 }
Example #2
0
 public function __construct(Request $request, Guard $auth)
 {
     // TODO: Add API keys and check here
     if ($sessionKey = $request->get('sessionKey')) {
         /** @var UserSession $session */
         $session = UserSession::find($sessionKey);
         if (!$session) {
             throw new NotFoundHttpException("The given sessionKey is invalid.");
         }
         if (!$session->user) {
             throw new NotFoundHttpException("The user for that session could not be found.");
         }
         // Login the user just for this request.
         $auth->setUser($session->user);
     }
     parent::__construct($request, $auth);
 }