mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-11 00:25:12 +00:00
feat: add default redirect uri and handling of unknown usernames (#3616)
* feat: add possibility to ignore username errors on first login screen * console changes * fix: handling of unknown usernames (#3445) * fix: handling of unknown usernames * fix: handle HideLoginNameSuffix on unknown users * feat: add default redirect uri on login policy (#3607) * feat: add default redirect uri on login policy * fix tests * feat: Console login policy default redirect (#3613) * console default redirect * placeholder * validate default redirect uri * allow empty default redirect uri Co-authored-by: Max Peintner <[email protected]> * remove wonrgly cherry picked migration Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
co-authored by
Max Peintner
parent
f1fa74a2c0
commit
411d7c6c5c
@@ -3,13 +3,16 @@ package login
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
http_mw "github.com/zitadel/zitadel/internal/api/http/middleware"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
tmplLogin = "login"
|
||||
tmplLogin = "login"
|
||||
queryOrgID = "orgID"
|
||||
)
|
||||
|
||||
type loginData struct {
|
||||
@@ -17,8 +20,8 @@ type loginData struct {
|
||||
Register bool `schema:"register"`
|
||||
}
|
||||
|
||||
func LoginLink(origin string) string {
|
||||
return externalLink(origin) + EndpointLogin
|
||||
func LoginLink(origin, orgID string) string {
|
||||
return externalLink(origin) + EndpointLogin + "?orgID=" + orgID
|
||||
}
|
||||
|
||||
func externalLink(origin string) string {
|
||||
@@ -32,12 +35,23 @@ func (l *Login) handleLogin(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if authReq == nil {
|
||||
http.Redirect(w, r, l.consolePath, http.StatusFound)
|
||||
l.defaultRedirect(w, r)
|
||||
return
|
||||
}
|
||||
l.renderNextStep(w, r, authReq)
|
||||
}
|
||||
|
||||
func (l *Login) defaultRedirect(w http.ResponseWriter, r *http.Request) {
|
||||
orgID := r.FormValue(queryOrgID)
|
||||
policy, err := l.getLoginPolicy(r, orgID)
|
||||
logging.OnError(err).WithField("orgID", orgID).Error("error loading login policy")
|
||||
redirect := l.consolePath
|
||||
if policy != nil && policy.DefaultRedirectURI != "" {
|
||||
redirect = policy.DefaultRedirectURI
|
||||
}
|
||||
http.Redirect(w, r, redirect, http.StatusFound)
|
||||
}
|
||||
|
||||
func (l *Login) handleLoginName(w http.ResponseWriter, r *http.Request) {
|
||||
authReq, err := l.getAuthRequest(r)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user