mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-21 14:31:32 +00:00

* feat: dynamic issuer * feat: default language from context * remove zitadel docs from defaults * remove ConsoleOverwriteDir * remove notification endpoints from defaults * custom domains in emails * remove (external) domain * external domain completely removed, console handling fixed * fix test * fix defaults.yaml
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package login
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
|
|
http_mw "github.com/caos/zitadel/internal/api/http/middleware"
|
|
)
|
|
|
|
const (
|
|
tmplUserSelection = "userselection"
|
|
)
|
|
|
|
type userSelectionFormData struct {
|
|
UserID string `schema:"userID"`
|
|
}
|
|
|
|
func (l *Login) renderUserSelection(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest, selectionData *domain.SelectUserStep) {
|
|
data := userSelectionData{
|
|
baseData: l.getBaseData(r, authReq, "Select User", "", ""),
|
|
Users: selectionData.Users,
|
|
Linking: len(authReq.LinkingUsers) > 0,
|
|
}
|
|
translator := l.getTranslator(r.Context(), authReq)
|
|
l.renderer.RenderTemplate(w, r, translator, l.renderer.Templates[tmplUserSelection], data, nil)
|
|
}
|
|
|
|
func (l *Login) handleSelectUser(w http.ResponseWriter, r *http.Request) {
|
|
data := new(userSelectionFormData)
|
|
authSession, err := l.getAuthRequestAndParseData(r, data)
|
|
if err != nil {
|
|
l.renderError(w, r, authSession, err)
|
|
return
|
|
}
|
|
if data.UserID == "0" {
|
|
l.renderLogin(w, r, authSession, nil)
|
|
return
|
|
}
|
|
userAgentID, _ := http_mw.UserAgentIDFromCtx(r.Context())
|
|
err = l.authRepo.SelectUser(r.Context(), authSession.ID, data.UserID, userAgentID)
|
|
if err != nil {
|
|
l.renderError(w, r, authSession, err)
|
|
return
|
|
}
|
|
l.renderNextStep(w, r, authSession)
|
|
}
|