mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fix: enable resend code in user initialization without auth request (#7568)
This commit is contained in:
parent
3be559038b
commit
20d1d56669
@ -22,6 +22,7 @@ type initPasswordFormData struct {
|
|||||||
Password string `schema:"password"`
|
Password string `schema:"password"`
|
||||||
PasswordConfirm string `schema:"passwordconfirm"`
|
PasswordConfirm string `schema:"passwordconfirm"`
|
||||||
UserID string `schema:"userID"`
|
UserID string `schema:"userID"`
|
||||||
|
OrgID string `schema:"orgID"`
|
||||||
Resend bool `schema:"resend"`
|
Resend bool `schema:"resend"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ func (l *Login) handleInitPasswordCheck(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if data.Resend {
|
if data.Resend {
|
||||||
l.resendPasswordSet(w, r, authReq)
|
l.resendPasswordSet(w, r, authReq, data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.checkPWCode(w, r, authReq, data)
|
l.checkPWCode(w, r, authReq, data)
|
||||||
@ -81,27 +82,20 @@ func (l *Login) checkPWCode(w http.ResponseWriter, r *http.Request, authReq *dom
|
|||||||
l.renderInitPasswordDone(w, r, authReq, userOrg)
|
l.renderInitPasswordDone(w, r, authReq, userOrg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Login) resendPasswordSet(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest) {
|
func (l *Login) resendPasswordSet(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest, data *initPasswordFormData) {
|
||||||
if authReq == nil {
|
userOrg := data.OrgID
|
||||||
l.renderError(w, r, nil, zerrors.ThrowInternal(nil, "LOGIN-8sn7s", "Errors.AuthRequest.NotFound"))
|
userID := data.UserID
|
||||||
return
|
|
||||||
}
|
|
||||||
userOrg := login
|
|
||||||
if authReq != nil {
|
if authReq != nil {
|
||||||
userOrg = authReq.UserOrgID
|
userOrg = authReq.UserOrgID
|
||||||
}
|
userID = authReq.UserID
|
||||||
user, err := l.query.GetUserByLoginName(setContext(r.Context(), userOrg), false, authReq.LoginName)
|
|
||||||
if err != nil {
|
|
||||||
l.renderInitPassword(w, r, authReq, authReq.UserID, "", err)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
passwordCodeGenerator, err := l.query.InitEncryptionGenerator(r.Context(), domain.SecretGeneratorTypePasswordResetCode, l.userCodeAlg)
|
passwordCodeGenerator, err := l.query.InitEncryptionGenerator(r.Context(), domain.SecretGeneratorTypePasswordResetCode, l.userCodeAlg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.renderInitPassword(w, r, authReq, authReq.UserID, "", err)
|
l.renderInitPassword(w, r, authReq, userID, "", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = l.command.RequestSetPassword(setContext(r.Context(), userOrg), user.ID, user.ResourceOwner, domain.NotificationTypeEmail, passwordCodeGenerator)
|
_, err = l.command.RequestSetPassword(setContext(r.Context(), userOrg), userID, userOrg, domain.NotificationTypeEmail, passwordCodeGenerator)
|
||||||
l.renderInitPassword(w, r, authReq, authReq.UserID, "", err)
|
l.renderInitPassword(w, r, authReq, userID, "", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Login) renderInitPassword(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest, userID, code string, err error) {
|
func (l *Login) renderInitPassword(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest, userID, code string, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user