Refresh session when user or role is updated

This commit is contained in:
cuigh 2022-01-06 14:58:43 +08:00
parent d0eb101aee
commit 48fdc6e094
3 changed files with 13 additions and 4 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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'))
}