From c7d5be908e24ee7677140c1cf983836f2e413cf0 Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期二, 10 十二月 2024 18:26:20 +0800 Subject: [PATCH] 会话菜单增加 --- app/service/auth.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/app/service/auth.py b/app/service/auth.py index d0436f8..46c42dd 100644 --- a/app/service/auth.py +++ b/app/service/auth.py @@ -9,6 +9,7 @@ from Log import logger from app.config.config import settings +from app.models import RoleModel, GroupModel from app.models.user_model import UserModel, UserAppModel SECRET_KEY = settings.secret_key @@ -71,7 +72,8 @@ db_user = UserModel(username=username, hashed_password=hashed_password, email=email) pwd = db_user.encrypted_password(password) db_user.password = pwd - db.add(db_user) + db_user.roles = [db.query(RoleModel).filter(RoleModel.role_type == 2).first()] + db_user.groups = [db.query(GroupModel).filter(GroupModel.group_type == 2).first()] db.add(db_user) db.commit() db.refresh(db_user) @@ -84,6 +86,7 @@ # db.roolback() if user_id: db.query(UserModel).filter(UserModel.id == user_id).delete() + db.commit return False return True -- Gitblit v1.8.0