mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: logout event log (#13916)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -41,6 +41,7 @@ import (
|
||||
compute_modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
|
||||
modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
"yunion.io/x/onecloud/pkg/util/netutils2"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
@@ -621,6 +622,12 @@ func (h *AuthHandlers) doLogin(ctx context.Context, w http.ResponseWriter, req *
|
||||
}
|
||||
|
||||
func (h *AuthHandlers) postLogoutHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
token, _, _ := fetchAuthInfo(ctx, req)
|
||||
if token != nil {
|
||||
// valid login, log the event
|
||||
user := logclient.NewSimpleObject(token.GetUserId(), token.GetUserName(), "user")
|
||||
logclient.AddActionLogWithContext(ctx, user, logclient.ACT_LOGOUT, "", token, true)
|
||||
}
|
||||
clearAuthCookie(w)
|
||||
appsrv.DisableClientCache(w)
|
||||
appsrv.Send(w, "")
|
||||
|
||||
@@ -120,6 +120,7 @@ const (
|
||||
ACT_IMAGE_PROBE = "image_probe"
|
||||
|
||||
ACT_AUTHENTICATE = "authenticate"
|
||||
ACT_LOGOUT = "logout"
|
||||
|
||||
ACT_HEALTH_CHECK = "health_check"
|
||||
|
||||
|
||||
@@ -398,6 +398,11 @@ func init() {
|
||||
CN("认证登录"),
|
||||
)
|
||||
|
||||
t.Set(ACT_LOGOUT, i18n.NewTableEntry().
|
||||
EN("Logout").
|
||||
CN("退出登录"),
|
||||
)
|
||||
|
||||
t.Set(ACT_HEALTH_CHECK, i18n.NewTableEntry().
|
||||
EN("Health Check").
|
||||
CN("健康检查"),
|
||||
|
||||
@@ -57,6 +57,32 @@ type IObject interface {
|
||||
Keyword() string
|
||||
}
|
||||
|
||||
type sSimpleObject struct {
|
||||
id string
|
||||
name string
|
||||
keyword string
|
||||
}
|
||||
|
||||
func (s sSimpleObject) GetId() string {
|
||||
return s.id
|
||||
}
|
||||
|
||||
func (s sSimpleObject) GetName() string {
|
||||
return s.name
|
||||
}
|
||||
|
||||
func (s sSimpleObject) Keyword() string {
|
||||
return s.keyword
|
||||
}
|
||||
|
||||
func NewSimpleObject(id, name, keyword string) IObject {
|
||||
return sSimpleObject{
|
||||
id: id,
|
||||
name: name,
|
||||
keyword: keyword,
|
||||
}
|
||||
}
|
||||
|
||||
type IVirtualObject interface {
|
||||
IObject
|
||||
GetOwnerId() mcclient.IIdentityProvider
|
||||
|
||||
Reference in New Issue
Block a user