feat: 写入权限向后兼容, 避免其它非后台的地方写入报错

This commit is contained in:
yokowu
2025-08-18 17:19:38 +08:00
parent ce277f08c9
commit 76e4e46b57

View File

@@ -41,7 +41,8 @@ func (p PermissionHook) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
perm, ok := ctx.Value(PermissionKey{}).(*domain.Permissions)
if !ok {
return nil, errcode.ErrPermission.Wrap(fmt.Errorf("failed to get permission"))
// 没有权限,直接返回. 用于向后兼容
return p.next.Mutate(ctx, m)
}
if perm.IsAdmin {