fix: 账套隔离 — register不再授予全部企业,仅授第一个active企业(防新用户越权)
This commit is contained in:
@@ -79,8 +79,12 @@ def register(data: dict, db: Session = Depends(get_db)):
|
||||
)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
# 新用户默认授予所有active企业
|
||||
_ensure_default_grants(db, user.id)
|
||||
db.refresh(user)
|
||||
# 注册默认授权第一个active企业(不授予全部,保证账套隔离)
|
||||
first_ent = db.query(Entity).filter(Entity.status == "active").order_by(Entity.id).first()
|
||||
if first_ent:
|
||||
db.add(UserEntity(user_id=user.id, entity_id=first_ent.id))
|
||||
db.commit()
|
||||
return {"message": "注册成功"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user