修改 LoginStatus 用 context 传递

This commit is contained in:
bjdgyc
2024-11-12 15:11:28 +08:00
parent 9ef29545bc
commit 2b757b65b6
3 changed files with 31 additions and 9 deletions

View File

@@ -109,7 +109,9 @@ func DeleteCookie(w http.ResponseWriter, name string) {
http.SetCookie(w, cookie)
}
func CreateSession(w http.ResponseWriter, r *http.Request, authSession *AuthSession) {
lockManager.LoginStatus.Store(loginStatusKey, true) // 更新登录成功状态
// lockManager.LoginStatus.Store(loginStatusKey, true) // 更新登录成功状态
hc := r.Context().Value(loginStatusKey).(*HttpContext)
hc.LoginStatus = true
cr := authSession.ClientRequest
ua := authSession.UserActLog
@@ -201,7 +203,9 @@ func LinkAuth_otp(w http.ResponseWriter, r *http.Request) {
// http.Error(w, "TooManyError, please login again", http.StatusBadRequest)
// return
// }
lockManager.LoginStatus.Store(loginStatusKey, false) // 记录登录失败状态
// lockManager.LoginStatus.Store(loginStatusKey, false) // 记录登录失败状态
hc := r.Context().Value(loginStatusKey).(*HttpContext)
hc.LoginStatus = false
base.Warn("OTP 动态码错误", username, r.RemoteAddr)
ua.Info = "OTP 动态码错误"