def post(self): json_data = request.get_json() if 'login' not in json_data: return jsonify({"msg": "NO_LOGIN"}) login = json_data['login'] find_user = get_database_session().query(User).filter( User.login == login).first() if not find_user: return jsonify({"msg": "NO_USER_WITH_THIS_LOGIN"}) roles = find_user.roles if 'SuperUser' in roles: return jsonify({ "msg": "Do you really wanna delete SuperUser??? This is madness!" }) get_database_session().delete(find_user) get_database().session.commit() return jsonify({"msg": "OK"})
def post(self): json_data = request.get_json() if 'login' not in json_data: return jsonify({"msg": "NO_LOGIN"}) password_hash = None if 'password' in json_data: password = '' password = json_data['password'] if password != None: password_hash = generate_password_hash(password=password) login = json_data['login'] find_user = get_database_session().query(User).filter( User.login == login).first() if find_user: return jsonify({"msg": "NOT_ORIGINAL_LOGIN"}) if 'roles' in json_data: roles = json_data['roles'] try: user = User(login=login, password_hash=password_hash, roles=Role.get_roles_from_string_array(roles)) get_database().session.add(user) get_database().session.commit() except: return jsonify({"msg": "WRONG_ROLES"}) else: user = User(login=login, password_hash=password_hash) get_database().session.add(user) get_database().session.commit() return jsonify({ "msg": "OK", "access_token": create_access_token(user.create_access_token_payload(), expires_delta=False), "roles": user.role_string_array })
class Meta: database = get_database() db_table = "tb_user_fav"
class Meta: database = get_database() table_name = 'tb_novel_chapter'
class Meta: database = get_database() db_table = 'tb_novel'
class Meta: database = get_database() table_name = "tb_novel_category"
class Meta: database = get_database() table_name = "tb_novel_author"
class Meta: database = get_database() table_name = 'proxys'
class Meta: database = get_database() db_table = "tb_user_message"
class Meta: database = get_database() db_table = "tb_user_profile"