From 48fdc6e0945e0a0b4252197fe0cff331887dd7a8 Mon Sep 17 00:00:00 2001 From: cuigh Date: Thu, 6 Jan 2022 14:58:43 +0800 Subject: [PATCH] Refresh session when user or role is updated --- biz/role.go | 10 ++++++++-- biz/user.go | 5 ++++- ui/src/pages/event/List.vue | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/biz/role.go b/biz/role.go index d94d7b3..e41f79d 100644 --- a/biz/role.go +++ b/biz/role.go @@ -50,7 +50,10 @@ func (b *roleBiz) Create(role *dao.Role, user web.User) (err error) { func (b *roleBiz) Delete(id, name string, user web.User) (err error) { err = b.d.RoleDelete(context.TODO(), id) if err == nil { - b.eb.CreateRole(EventActionDelete, id, name, user) + go func() { + _ = b.d.SessionUpdateDirty(context.TODO(), "", id) + b.eb.CreateRole(EventActionDelete, id, name, user) + }() } return } @@ -70,7 +73,10 @@ func (b *roleBiz) Update(role *dao.Role, user web.User) (err error) { } err = b.d.RoleUpdate(context.TODO(), r) if err == nil { - b.eb.CreateRole(EventActionUpdate, role.ID, role.Name, user) + go func() { + _ = b.d.SessionUpdateDirty(context.TODO(), "", role.ID) + b.eb.CreateRole(EventActionUpdate, role.ID, role.Name, user) + }() } return } diff --git a/biz/user.go b/biz/user.go index 5fd7bf6..46e5010 100644 --- a/biz/user.go +++ b/biz/user.go @@ -126,7 +126,10 @@ func (b *userBiz) Update(user *dao.User, ctxUser web.User) (err error) { user.UpdatedAt = now() user.UpdatedBy = newOperator(ctxUser) if err = b.d.UserUpdate(context.TODO(), user); err == nil { - b.eb.CreateUser(EventActionUpdate, user.LoginName, user.Name, ctxUser) + go func() { + _ = b.d.SessionUpdateDirty(context.TODO(), user.ID, "") + b.eb.CreateUser(EventActionUpdate, user.LoginName, user.Name, ctxUser) + }() } return } diff --git a/ui/src/pages/event/List.vue b/ui/src/pages/event/List.vue index 84a83bf..e1e4ef5 100644 --- a/ui/src/pages/event/List.vue +++ b/ui/src/pages/event/List.vue @@ -203,7 +203,7 @@ function renderObject(e: Event) { return renderLink({ name: e.type.toLowerCase() + '_detail', params: { name: e.args.name } }, e.args.name) case "Image": if (e.args.id) { - return renderLink({ name: 'image_detail', params: { node: e.args.node || '-', id: e.args.id } }, e.args.id) + return renderLink({ name: 'image_detail', params: { node: e.args.node || '-', id: e.args.id } }, e.args.id.substring(7, 19)) } else { return renderLink({ name: 'image_list' }, t('objects.image')) }