Пример #1
0
    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"})
Пример #2
0
    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
        })
Пример #3
0
 class Meta:
     database = get_database()
     db_table = "tb_user_fav"
Пример #4
0
 class Meta:
     database = get_database()
     table_name = 'tb_novel_chapter'
Пример #5
0
 class Meta:
     database = get_database()
     db_table = 'tb_novel'
Пример #6
0
 class Meta:
     database = get_database()
     table_name = "tb_novel_category"
Пример #7
0
 class Meta:
     database = get_database()
     table_name = "tb_novel_author"
Пример #8
0
 class Meta:
     database = get_database()
     table_name = 'proxys'
Пример #9
0
 class Meta:
     database = get_database()
     db_table = "tb_user_message"
Пример #10
0
 class Meta:
     database = get_database()
     db_table = "tb_user_profile"