Commit 2cc6bacf authored by Viral Solani's avatar Viral Solani

Sucessful Response message through common function

parent 0eec4a29
...@@ -42,7 +42,10 @@ class AuthController extends APIController ...@@ -42,7 +42,10 @@ class AuthController extends APIController
return $this->throwValidation('Your account hasn\'t been activated. Please check your email & activate account.'); return $this->throwValidation('Your account hasn\'t been activated. Please check your email & activate account.');
} }
return response()->json(['message' => 'You are successfully logged in!', 'token' => $token]); return $this->respond([
'message' => 'You are successfully logged in!',
'token' => $token
]);
} }
public function check() public function check()
...@@ -56,6 +59,11 @@ class AuthController extends APIController ...@@ -56,6 +59,11 @@ class AuthController extends APIController
return response(['authenticated' => true]); return response(['authenticated' => true]);
} }
/**
* Log Out
*
* @return JSON Response
*/
public function logout() public function logout()
{ {
try { try {
...@@ -65,10 +73,12 @@ class AuthController extends APIController ...@@ -65,10 +73,12 @@ class AuthController extends APIController
JWTAuth::invalidate($token); JWTAuth::invalidate($token);
} }
} catch (JWTException $e) { } catch (JWTException $e) {
return response()->json($e->getMessage(), 500); return $this->respondInternalError('This is something wrong. Please try again!');
} }
return response()->json(['message' => 'You are successfully logged out!']); return $this->respond([
'message' => 'You are successfully logged out!'
]);
} }
public function register(Request $request) public function register(Request $request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment