mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 15:37:32 +00:00
feat: request registration process by prompt (#1798)
* feat: request registration process by prompt * fix merge * add prompt create to docs
This commit is contained in:
@@ -171,6 +171,8 @@ func PromptToBusiness(prompt oidc.Prompt) domain.Prompt {
|
||||
return domain.PromptConsent
|
||||
case oidc.PromptSelectAccount:
|
||||
return domain.PromptSelectAccount
|
||||
case "create": //this prompt is not final yet, so not implemented in oidc lib
|
||||
return domain.PromptCreate
|
||||
default:
|
||||
return domain.PromptUnspecified
|
||||
}
|
||||
|
@@ -532,6 +532,9 @@ func (repo *AuthRequestRepo) nextSteps(ctx context.Context, request *domain.Auth
|
||||
return steps, nil
|
||||
}
|
||||
steps = append(steps, new(domain.LoginStep))
|
||||
if request.Prompt == domain.PromptCreate {
|
||||
return append(steps, &domain.RegistrationStep{}), nil
|
||||
}
|
||||
if request.Prompt == domain.PromptSelectAccount || request.Prompt == domain.PromptUnspecified {
|
||||
users, err := repo.usersForUserSelection(request)
|
||||
if err != nil {
|
||||
|
@@ -72,6 +72,7 @@ const (
|
||||
PromptLogin
|
||||
PromptConsent
|
||||
PromptSelectAccount
|
||||
PromptCreate
|
||||
)
|
||||
|
||||
type LevelOfAssurance int
|
||||
|
@@ -24,6 +24,7 @@ const (
|
||||
NextStepExternalLogin
|
||||
NextStepGrantRequired
|
||||
NextStepPasswordless
|
||||
NextStepRegistration
|
||||
)
|
||||
|
||||
type LoginStep struct{}
|
||||
@@ -32,6 +33,12 @@ func (s *LoginStep) Type() NextStepType {
|
||||
return NextStepLogin
|
||||
}
|
||||
|
||||
type RegistrationStep struct{}
|
||||
|
||||
func (s *RegistrationStep) Type() NextStepType {
|
||||
return NextStepRegistration
|
||||
}
|
||||
|
||||
type SelectUserStep struct {
|
||||
Users []UserSelection
|
||||
}
|
||||
|
@@ -3,10 +3,10 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
http_mw "github.com/caos/zitadel/internal/api/http/middleware"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
@@ -82,7 +82,12 @@ func (l *Login) handleRegisterCheck(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, l.zitadelURL, http.StatusFound)
|
||||
return
|
||||
}
|
||||
authRequest.LoginName = user.PreferredLoginName
|
||||
userAgentID, _ := http_mw.UserAgentIDFromCtx(r.Context())
|
||||
err = l.authRepo.SelectUser(r.Context(), authRequest.ID, user.AggregateID, userAgentID)
|
||||
if err != nil {
|
||||
l.renderRegister(w, r, authRequest, data, err)
|
||||
return
|
||||
}
|
||||
l.renderNextStep(w, r, authRequest)
|
||||
}
|
||||
|
||||
|
@@ -8,18 +8,17 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
"github.com/caos/zitadel/internal/static"
|
||||
|
||||
"github.com/caos/logging"
|
||||
"github.com/gorilla/csrf"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
http_mw "github.com/caos/zitadel/internal/api/http/middleware"
|
||||
"github.com/caos/zitadel/internal/auth_request/model"
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/i18n"
|
||||
"github.com/caos/zitadel/internal/renderer"
|
||||
"github.com/caos/zitadel/internal/static"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -238,6 +237,8 @@ func (l *Login) chooseNextStep(w http.ResponseWriter, r *http.Request, authReq *
|
||||
return
|
||||
}
|
||||
l.renderLogin(w, r, authReq, err)
|
||||
case *domain.RegistrationStep:
|
||||
l.renderRegisterOption(w, r, authReq, nil)
|
||||
case *domain.SelectUserStep:
|
||||
l.renderUserSelection(w, r, authReq, step)
|
||||
case *domain.InitPasswordStep:
|
||||
|
@@ -22,9 +22,8 @@
|
||||
formnovalidate>{{t "RegisterOption.RegisterUsernamePassword"}}</button>
|
||||
{{end}}
|
||||
|
||||
<p>{{t "Registration.ExternalLogin"}}</p>
|
||||
|
||||
{{if .LoginPolicy.AllowExternalIDP}}
|
||||
{{if hasExternalLogin}}
|
||||
<p>{{t "Registration.ExternalLogin"}}</p>
|
||||
{{ $reqid := .AuthReqID}}
|
||||
{{range $provider := .IDPProviders}}
|
||||
<a href="{{ externalIDPRegisterURL $reqid $provider.IDPConfigID}}"
|
||||
|
Reference in New Issue
Block a user