Skip to content

Commit

Permalink
bugfix:修复管理员提示无权限问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed Aug 28, 2024
1 parent bebca65 commit d753147
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ DB_CONNECT_URL=mysql://root:[email protected]:3306/data
APP_MODE=production

# allow commands eg:
ALLOW_COMMANDS=/opt/nginx/sbin/nginx -s reload
ALLOW_COMMANDS=/opt/nginx/sbin/nginx -s reload

# allow user register
ENABLED_REGISTER=true

# icp
ICP=
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
- 修复zerossl无法申请的问题
- fix #126
- 版本升级
- fix
- 修改权限策略
- add zerossl
- 优化权限控制
Expand Down
4 changes: 3 additions & 1 deletion domain_admin/api/system_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from flask import request, g

from domain_admin import version
from domain_admin import config
from domain_admin.enums.config_key_enum import ConfigKeyEnum
from domain_admin.enums.monitor_status_enum import MonitorStatusEnum
from domain_admin.enums.role_enum import RoleEnum
Expand Down Expand Up @@ -121,7 +122,8 @@ def get_system_version():
:return:
"""
return {
'version': version.VERSION
'version': version.VERSION,
'enabled_register': config.ENABLED_REGISTER
}


Expand Down
3 changes: 3 additions & 0 deletions domain_admin/config/env_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@

# ALLOW_COMMANDS
ALLOW_COMMANDS = [cmd.strip() for cmd in env.str("ALLOW_COMMANDS", '').split(';') if cmd.strip()]

# ENABLED_REGISTER
ENABLED_REGISTER = env.str("ENABLED_REGISTER", 'false')
2 changes: 2 additions & 0 deletions domain_admin/enums/version_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,5 @@ class VersionEnum(object):
Version_1645 = '1.6.45'
Version_1646 = '1.6.46'
Version_1647 = '1.6.47'
Version_1648 = '1.6.48'
Version_1649 = '1.6.49'
29 changes: 29 additions & 0 deletions domain_admin/migrate/history/migrate_1647_to_1648.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
"""
@File : migrate_1647_to_1648.py
@Date : 2024-08-28
cmd:
$ python domain_admin/migrate/migrate_1647_to_1648.py
"""
from __future__ import print_function, unicode_literals, absolute_import, division

from domain_admin.config import ADMIN_USERNAME
from domain_admin.enums.role_enum import RoleEnum
from domain_admin.migrate import migrate_common
from domain_admin.model.base_model import db
from domain_admin.model.issue_certificate_model import IssueCertificateModel, DeployStatusEnum
from domain_admin.model.tag_model import TagModel
from domain_admin.model.user_model import UserModel


def execute_migrate():
"""
版本升级 1.6.47 => 1.6.48
:return:
"""
UserModel.update(
role=RoleEnum.ADMIN
).where(
UserModel.username == ADMIN_USERNAME
).execute()
13 changes: 12 additions & 1 deletion domain_admin/migrate/migrate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
migrate_162_to_163,
migrate_168_to_169,
migrate_1610_to_1611,
migrate_1625_to_1626, migrate_1633_to_1634, migrate_1634_to_1635, migrate_1642_to_1643, migrate_1646_to_1647)
migrate_1625_to_1626, migrate_1633_to_1634, migrate_1634_to_1635, migrate_1642_to_1643, migrate_1646_to_1647,
migrate_1647_to_1648)

# 参数说明
# local_versions 本地版本
Expand Down Expand Up @@ -428,4 +429,14 @@
'migrate_func': migrate_1646_to_1647.execute_migrate,
'update_version': VersionEnum.Version_1647
},
# 2024-08-28
# 版本升级 1.6.47 => 1.6.48
{
'local_versions': [
VersionEnum.Version_1647,
],
'migrate_func': migrate_1647_to_1648.execute_migrate,
'update_version': VersionEnum.Version_1648
},

]
1 change: 1 addition & 0 deletions domain_admin/model/user_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def init_table_data():
{
'username': ADMIN_USERNAME,
'password': bcrypt_util.encode_password(ADMIN_PASSWORD),
'role': RoleEnum.ADMIN
}
]

Expand Down
1 change: 1 addition & 0 deletions domain_admin/utils/flask_ext/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def error_handler(e):
:return:
"""

logger.error("request.path: %s", request.path)
logger.error(traceback.format_exc())

if request.path.startswith('/api'):
Expand Down

0 comments on commit d753147

Please sign in to comment.