mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-09 20:56:47 +00:00

* start v2 * start * run * some cleanup * remove v2 pkg again * simplify * webauthn * remove unused config * fix login path in Dockerfile * fix asset_generator.go * health handler * fix grpc web * refactor * merge * build new main.go * run new main.go * update logging pkg * fix error msg * update logging * cleanup * cleanup * go mod tidy * change localDevMode * fix customEndpoints * update logging * comments * change local flag to external configs * fix location generated go code * fix Co-authored-by: fforootd <florian@caos.ch>
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package login
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
)
|
|
|
|
const (
|
|
tmplLoginSuccess = "login_success"
|
|
)
|
|
|
|
type loginSuccessData struct {
|
|
userData
|
|
RedirectURI string `schema:"redirect-uri"`
|
|
}
|
|
|
|
func (l *Login) redirectToLoginSuccess(w http.ResponseWriter, r *http.Request, id string) {
|
|
http.Redirect(w, r, l.renderer.pathPrefix+EndpointLoginSuccess+"?authRequestID="+id, http.StatusFound)
|
|
}
|
|
|
|
func (l *Login) handleLoginSuccess(w http.ResponseWriter, r *http.Request) {
|
|
authRequest, _ := l.getAuthRequest(r)
|
|
if authRequest == nil {
|
|
l.renderSuccessAndCallback(w, r, nil, nil)
|
|
return
|
|
}
|
|
for _, step := range authRequest.PossibleSteps {
|
|
if step.Type() != domain.NextStepLoginSucceeded && step.Type() != domain.NextStepRedirectToCallback {
|
|
l.renderNextStep(w, r, authRequest)
|
|
return
|
|
}
|
|
}
|
|
l.renderSuccessAndCallback(w, r, authRequest, nil)
|
|
}
|
|
|
|
func (l *Login) renderSuccessAndCallback(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest, err error) {
|
|
var errID, errMessage string
|
|
if err != nil {
|
|
errID, errMessage = l.getErrorMessage(r, err)
|
|
}
|
|
data := loginSuccessData{
|
|
userData: l.getUserData(r, authReq, "Login Successful", errID, errMessage),
|
|
}
|
|
if authReq != nil {
|
|
data.RedirectURI = l.oidcAuthCallbackURL
|
|
}
|
|
l.renderer.RenderTemplate(w, r, l.getTranslator(authReq), l.renderer.Templates[tmplLoginSuccess], data, nil)
|
|
}
|
|
|
|
func (l *Login) redirectToCallback(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest) {
|
|
callback := l.oidcAuthCallbackURL + authReq.ID
|
|
http.Redirect(w, r, callback, http.StatusFound)
|
|
}
|