app/Http/Controllers/AuthJwt/AuthController.php
/**
     * Get a JWT via given credentials.
     *
     * @return \Illuminate\Http\JsonResponse
     */
Get a JWT via given credentials.
Get a JWT via given credentials .
public function login(LoginRequest $request)
    {
       $credentials = $request->only('email', 'password');
        try {
            if (! $token = auth('api-jwt')->attempt($credentials)) {
                return response()->json([
                    'success' => false,
                    'errors'=>['credentials'=>['Login credentials are invalid']]
                ], 402);
            }
        } catch (JWTException $e) {
            return response()->json([
                'success' => false,
                'message' => 'Could not create token.',
                'errors'=>[$credentials]
            ], 500);
        }
        return $this->respondWithToken($token);
    }
public function login ( LoginRequest $ request ) { $ credentials = $ request -> only ( 'email' , 'password' ) ; try { if ( ! $ token = auth ( 'api-jwt' ) -> attempt ( $ credentials ) ) { return response ( ) -> json ( [ 'success' => false , 'errors' => [ 'credentials' => [ 'Login credentials are invalid' ] ] ] , 402 ) ; } } catch ( JWTException $ e ) { return response ( ) -> json ( [ 'success' => false , 'message' => 'Could not create token.' , 'errors' => [ $ credentials ] ] , 500 ) ; } return $ this -> respondWithToken ( $ token ) ; }
Get a JWT via given credentials.
Get a JWT via given credentials .