mercredi 5 octobre 2016

Laravel JWT Auth get user on Login

Is it possible with http://ift.tt/1GFm4Yr to get the current user? Because right now I can only generate a token (when a user sign in).

public function login(Request $request)
{
    $credentials = $request->only('email', 'password');

    try {
        if (! $token = JWTAuth::attempt($credentials)) {
            return response()->json(['error' => 'invalid_credentials'], 401);
        }
    } catch (Tymon\JWTAuth\Exceptions\JWTException $e) {
        return response()->json(['error' => 'could_not_create_token'], 500);
    }

    return response()->json(compact('token'));
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire