mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-21 20:23:41 +09:00
feat: Add audit logging (#38189)
Co-authored-by: bircni <bircni@users.noreply.github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
bircni
wxiaoguang
parent
4d43445532
commit
da37b7916b
@@ -42,6 +42,17 @@ func ImpersonateUser(sess SessionStore, u *user_model.User) error {
|
||||
return sess.Release()
|
||||
}
|
||||
|
||||
// ImpersonatorUserID returns the ID of the admin behind an impersonated
|
||||
// session, or zero when the session is not impersonating anyone.
|
||||
func ImpersonatorUserID(sess SessionStore) int64 {
|
||||
data, ok := sess.Get(session.KeyImpersonatorData).(map[string]any)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
uid, _ := data[session.KeyUID].(int64)
|
||||
return uid
|
||||
}
|
||||
|
||||
func ExitImpersonatedUser(sess SessionStore) (bool, error) {
|
||||
impersonatorData, ok := sess.Get(session.KeyImpersonatorData).(map[string]any)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user