def post(email: str, password: str): if UserRepository.find_by_email(email): return {"message": "Email already exits"}, 400 else: user = UserRepository.create( email=email, password=generate_password_hash(password)) return user.json
def post(email: str, password: str): user = UserRepository.find_by_email(email) if not user or email != user.email or not check_password_hash( user.password, password): return {"message": "Bad username or password"}, 400 access_token = create_access_token(identity=email) return {"access_token": access_token}, 200
def get(self): # return 'authorized resource' # Access the identity of the current user with get_jwt_identity current_user_email = get_jwt_identity() user = UserRepository.find_by_email(current_user_email) return user.json