mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-07 14:54:39 +00:00

* feat: set cookie prefix and max age * cookie prefix on csrf cookie * fix: check user agent cookie in login * update oidc pkg * cleanup
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
http_mw "github.com/caos/zitadel/internal/api/http/middleware"
|
|
"github.com/caos/zitadel/internal/auth_request/model"
|
|
)
|
|
|
|
const (
|
|
tmplPassword = "password"
|
|
)
|
|
|
|
type passwordFormData struct {
|
|
Password string `schema:"password"`
|
|
}
|
|
|
|
func (l *Login) renderPassword(w http.ResponseWriter, r *http.Request, authReq *model.AuthRequest, err error) {
|
|
var errType, errMessage string
|
|
if err != nil {
|
|
errMessage = l.getErrorMessage(r, err)
|
|
}
|
|
data := l.getUserData(r, authReq, "Password", errType, errMessage)
|
|
l.renderer.RenderTemplate(w, r, l.renderer.Templates[tmplPassword], data, nil)
|
|
}
|
|
|
|
func (l *Login) handlePasswordCheck(w http.ResponseWriter, r *http.Request) {
|
|
data := new(passwordFormData)
|
|
authReq, err := l.getAuthRequestAndParseData(r, data)
|
|
if err != nil {
|
|
l.renderError(w, r, authReq, err)
|
|
return
|
|
}
|
|
userAgentID, _ := http_mw.UserAgentIDFromCtx(r.Context())
|
|
err = l.authRepo.VerifyPassword(setContext(r.Context(), authReq.UserOrgID), authReq.ID, authReq.UserID, data.Password, userAgentID, model.BrowserInfoFromRequest(r))
|
|
if err != nil {
|
|
l.renderPassword(w, r, authReq, err)
|
|
return
|
|
}
|
|
l.renderNextStep(w, r, authReq)
|
|
}
|