for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Install GitHub App
<?php
namespace DoeSangue\Http\Controllers\Auth;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
use DoeSangue\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DoeSangue\Http\Requests;
use DoeSangue\Models\User;
class AuthenticateController extends Controller
{
public function authenticate(Request $request)
// grab credentials from the request
$credentials = $request->only('email', 'password');
try {
// attempt to verify the credentials and create a token for the user
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
// something went wrong whilst attempting to encode the token
return response()->json(['error' => 'could_not_create_token'], 500);
// all good so return the token
return response()->json([
'access_token' => $token,
'token_type' => 'bearer'
]);