Clear KV from session after showing it to user
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
func (h *AuthHandlers) changePasswordForm(req *request.AuthReq) error {
|
||||
h.Log.Debug("showing password change form")
|
||||
req.Template = TmplChangePassword
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ type (
|
||||
|
||||
func (h *AuthHandlers) loginForm(req *request.AuthReq) error {
|
||||
req.Template = TmplLogin
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func (h AuthHandlers) mfaForm(req *request.AuthReq) (err error) {
|
||||
req.RedirectTo = GetLinks().Mfa
|
||||
}
|
||||
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
req.Data["emailOtpDisabled"] = req.AuthUser.DisabledEmailOTP()
|
||||
req.Data["emailOtpPending"] = req.AuthUser.PendingEmailOTP()
|
||||
req.Data["totpDisabled"] = req.AuthUser.DisabledTOTP()
|
||||
|
||||
@@ -43,9 +43,8 @@ func (h AuthHandlers) mfaTotpConfigForm(req *request.AuthReq) (err error) {
|
||||
|
||||
req.Data["secret"] = secret
|
||||
req.Data["enforced"] = h.Settings.MultiFactor.TOTP.Enforced
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
req.Template = TmplMfaTotp
|
||||
req.SetKV(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -154,9 +153,8 @@ func (h AuthHandlers) mfaTotpConfigQR(req *request.AuthReq) (err error) {
|
||||
//
|
||||
// Where the TOTP QR & code are displayed and where
|
||||
func (h AuthHandlers) mfaTotpDisableForm(req *request.AuthReq) (err error) {
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
req.Template = TmplMfaTotpDisable
|
||||
req.SetKV(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func (h *AuthHandlers) requestPasswordResetForm(req *request.AuthReq) error {
|
||||
h.Log.Debug("showing request password reset form")
|
||||
req.Template = TmplRequestPasswordReset
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (h *AuthHandlers) resetPasswordForm(req *request.AuthReq) (err error) {
|
||||
})
|
||||
}
|
||||
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,8 @@ func (h *AuthHandlers) profileForm(req *request.AuthReq) error {
|
||||
req.Template = TmplProfile
|
||||
u := req.AuthUser.User
|
||||
|
||||
if form := req.GetKV(); len(form) > 0 {
|
||||
if form := req.PopKV(); len(form) > 0 {
|
||||
req.Data["form"] = form
|
||||
req.SetKV(nil)
|
||||
} else {
|
||||
req.Data["form"] = map[string]string{
|
||||
"email": u.Email,
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
func (h *AuthHandlers) signupForm(req *request.AuthReq) error {
|
||||
req.Template = TmplSignup
|
||||
req.Data["form"] = req.GetKV()
|
||||
req.Data["form"] = req.PopKV()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,12 @@ func (req *AuthReq) SetKV(val map[string]string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (req *AuthReq) PopKV() map[string]string {
|
||||
val := req.GetKV()
|
||||
req.SetKV(nil)
|
||||
return val
|
||||
}
|
||||
|
||||
func ExtraReqInfoMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), ExtraReqInfo{}, ExtraReqInfo{
|
||||
|
||||
Reference in New Issue
Block a user