def auth(username, password): user = UserModel.find_by_username(username) password = password.encode('utf-8') print(password) if UserModel.check_password(username, password): return user else: return None
def post(self): try: data = user_schema.load(request.get_json()) except ValidationError as err: return err.messages,400 username = data.username email = data.email password = data.password user = UserModel.find_by_username(username) if user and UserModel.check_password(username,password): if user.activated: access_token = create_access_token(identity=user.id,fresh=True) refresh_token = create_refresh_token(user.id) return { "access_token": access_token, "refresh_token": refresh_token },200 return {"msg": "User has not yet been activated"},401 return {"msg": "wrong creds"},401