feat: admin impersonates a user (#38614)

* fix #3631
* fix #21599

by the way, refactored the "profile avatar card" to simplify the code.
This commit is contained in:
wxiaoguang
2026-07-26 17:26:02 +00:00
committed by GitHub
parent 470d34b1de
commit a3caf21440
18 changed files with 278 additions and 238 deletions
+4 -2
View File
@@ -11,6 +11,7 @@ import (
user_model "gitea.dev/models/user"
"gitea.dev/modules/log"
"gitea.dev/modules/optional"
"gitea.dev/modules/session"
"gitea.dev/modules/setting"
gouuid "github.com/google/uuid"
@@ -117,8 +118,9 @@ func (r *ReverseProxy) Verify(req *http.Request, w http.ResponseWriter, store Da
}
}
if r.CreateSession {
if sess != nil && (sess.Get("uid") == nil || sess.Get("uid").(int64) != user.ID) {
if r.CreateSession && sess != nil {
sessionUID, ok := sess.Get(session.KeyUID).(int64)
if !ok || sessionUID != user.ID {
handleSignIn(w, req, sess, user)
}
}