def post(self):
        data = UserRegister.parser.parse_args()

        if UserModel.get_by_name(data["username"]):
            return {
                "message": "User: {}, already exists".format(data["username"])
            }, 400

        item = UserModel(data["username"], data["password"])
        item.save()
        return "User created successfully"
def authenticate(username, password):
    user = UserModel.get_by_name(username) #username_mapping.get(username, None)
    if user and safe_str_cmp(user.password, password):
        return user