app/Http/Controllers/Api/Auth/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(Request $request)
    {
        $credentials = request(['email', 'password']);
        $user = User::where('email', $credentials['email'])->first();
        if (!$user)
            return response()->json(['error' => 'Unauthorized']);
        if (!$token = auth()->attempt($credentials)) {
            return response()->json(['error' => 'Unauthorized'], 401);
        }
        $token = $this->getToken($token);
        return response()->json(['token' => $token, 'user' => $user], 200);
    }
public function login ( Request $ request ) { $ credentials = request ( [ 'email' , 'password' ] ) ; $ user = User :: where ( 'email' , $ credentials [ 'email' ] ) -> first ( ) ; if ( ! $ user ) return response ( ) -> json ( [ 'error' => 'Unauthorized' ] ) ; if ( ! $ token = auth ( ) -> attempt ( $ credentials ) ) { return response ( ) -> json ( [ 'error' => 'Unauthorized' ] , 401 ) ; } $ token = $ this -> getToken ( $ token ) ; return response ( ) -> json ( [ 'token' => $ token , 'user' => $ user ] , 200 ) ; }
Get a JWT via given credentials.
Get a JWT via given credentials .
//        dd($credentials); //        $token = null; //        dd($user); //        dd($user); //        dd(auth()->attempt($credentials));