app/Http/Controllers/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)
    {
        $validator = Validator::make($request->all(),
            [
                'email' => 'required|email',
                'password' => 'required|string|min:6',
            ]);
        if ($validator->fails()) {
            return response()->json($validator->errors(), 422);
        }
        $user = User::where('email', $request->email)->first();
        if ($user && !$user->is_active) {
            return response()->json(['message' => 'User not found'], 403);
        }
        if (!$token = auth()->attempt($validator->validated())) {
            return response()->json(['error' => 'Unauthorized'], 401);
        }
        return $this->createNewToken($token);
    }
public function login ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'email' => 'required|email' , 'password' => 'required|string|min:6' , ] ) ; if ( $ validator -> fails ( ) ) { return response ( ) -> json ( $ validator -> errors ( ) , 422 ) ; } $ user = User :: where ( 'email' , $ request -> email ) -> first ( ) ; if ( $ user && ! $ user -> is_active ) { return response ( ) -> json ( [ 'message' => 'User not found' ] , 403 ) ; } if ( ! $ token = auth ( ) -> attempt ( $ validator -> validated ( ) ) ) { return response ( ) -> json ( [ 'error' => 'Unauthorized' ] , 401 ) ; } return $ this -> createNewToken ( $ token ) ; }
Get a JWT via given credentials.
Get a JWT via given credentials .