mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-02 06:43:23 +08:00
feat: 写入权限向后兼容, 避免其它非后台的地方写入报错
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user