fix: tos on external registration (#2164)

* faet: add tos checkbox to external login

* fix: add tos to external not found option

* fix: add tos to external not found option

* fix: show register external user overview

* fix: no init user mail on external register

* fix: custom login text

* add missing custom text tests on org

* add missing custom text tests on iam

* fix: custom login text external registration overview tests

* fix: back button on registration overview

* fix: add texts, change register form

* fix: external not found html

* fix: remove form validation

Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
Fabi
2021-08-11 11:50:03 +00:00
committed by GitHub
co-authored by Livio Amstutz
parent 87fa6e58fb
commit b104011418
28 changed files with 3412 additions and 164 deletions
+94
View File
@@ -40,6 +40,7 @@ func (c *Commands) createAllLoginTextEvents(ctx context.Context, agg *eventstore
events = append(events, c.createPasswordResetDoneEvents(ctx, agg, existingText, text, defaultText)...)
events = append(events, c.createRegistrationOptionEvents(ctx, agg, existingText, text, defaultText)...)
events = append(events, c.createRegistrationUserEvents(ctx, agg, existingText, text, defaultText)...)
events = append(events, c.createExternalRegistrationUserOverviewEvents(ctx, agg, existingText, text, defaultText)...)
events = append(events, c.createRegistrationOrgEvents(ctx, agg, existingText, text, defaultText)...)
events = append(events, c.createLinkingUserEvents(ctx, agg, existingText, text, defaultText)...)
events = append(events, c.createExternalUserNotFoundEvents(ctx, agg, existingText, text, defaultText)...)
@@ -664,6 +665,10 @@ func (c *Commands) createPasswordlessRegistrationDoneEvents(ctx context.Context,
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyPasswordlessRegistrationDoneCancelButtonText, existingText.PasswordlessRegistrationDoneCancelButtonText, text.PasswordlessRegistrationDone.CancelButtonText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
return events
}
@@ -832,6 +837,75 @@ func (c *Commands) createRegistrationUserEvents(ctx context.Context, agg *events
return events
}
func (c *Commands) createExternalRegistrationUserOverviewEvents(ctx context.Context, agg *eventstore.Aggregate, existingText *CustomLoginTextReadModel, text *domain.CustomLoginText, defaultText bool) []eventstore.EventPusher {
events := make([]eventstore.EventPusher, 0)
event := c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewTitle, existingText.ExternalRegistrationUserOverviewTitle, text.ExternalRegistrationUserOverview.Title, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewDescription, existingText.ExternalRegistrationUserOverviewDescription, text.ExternalRegistrationUserOverview.Description, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewEmailLabel, existingText.ExternalRegistrationUserOverviewEmailLabel, text.ExternalRegistrationUserOverview.EmailLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewUsernameLabel, existingText.ExternalRegistrationUserOverviewUsernameLabel, text.ExternalRegistrationUserOverview.UsernameLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewFirstnameLabel, existingText.ExternalRegistrationUserOverviewFirstnameLabel, text.ExternalRegistrationUserOverview.FirstnameLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewLastnameLabel, existingText.ExternalRegistrationUserOverviewLastnameLabel, text.ExternalRegistrationUserOverview.LastnameLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewNicknameLabel, existingText.ExternalRegistrationUserOverviewNicknameLabel, text.ExternalRegistrationUserOverview.NicknameLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewLanguageLabel, existingText.ExternalRegistrationUserOverviewLanguageLabel, text.ExternalRegistrationUserOverview.LanguageLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewPhoneLabel, existingText.ExternalRegistrationUserOverviewPhoneLabel, text.ExternalRegistrationUserOverview.PhoneLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewTOSAndPrivacyLabel, existingText.ExternalRegistrationUserOverviewTOSAndPrivacyLabel, text.ExternalRegistrationUserOverview.TOSAndPrivacyLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewTOSConfirm, existingText.ExternalRegistrationUserOverviewTOSConfirm, text.ExternalRegistrationUserOverview.TOSConfirm, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewTOSLinkText, existingText.ExternalRegistrationUserOverviewTOSLinkText, text.ExternalRegistrationUserOverview.TOSLinkText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewTOSConfirmAnd, existingText.ExternalRegistrationUserOverviewTOSConfirmAnd, text.ExternalRegistrationUserOverview.TOSConfirmAnd, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewPrivacyLinkText, existingText.ExternalRegistrationUserOverviewPrivacyLinkText, text.ExternalRegistrationUserOverview.PrivacyLinkText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewBackButtonText, existingText.ExternalRegistrationUserOverviewBackButtonText, text.ExternalRegistrationUserOverview.BackButtonText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalRegistrationUserOverviewNextButtonText, existingText.ExternalRegistrationUserOverviewNextButtonText, text.ExternalRegistrationUserOverview.NextButtonText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
return events
}
func (c *Commands) createRegistrationOrgEvents(ctx context.Context, agg *eventstore.Aggregate, existingText *CustomLoginTextReadModel, text *domain.CustomLoginText, defaultText bool) []eventstore.EventPusher {
events := make([]eventstore.EventPusher, 0)
event := c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyRegisterOrgTitle, existingText.RegisterOrgTitle, text.RegistrationOrg.Title, text.Language, defaultText)
@@ -936,6 +1010,26 @@ func (c *Commands) createExternalUserNotFoundEvents(ctx context.Context, agg *ev
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSAndPrivacyLabel, existingText.ExternalUserNotFoundTOSAndPrivacyLabel, text.ExternalNotFoundOption.TOSAndPrivacyLabel, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSConfirm, existingText.ExternalUserNotFoundTOSConfirm, text.ExternalNotFoundOption.TOSConfirm, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSLinkText, existingText.ExternalUserNotFoundTOSLinkText, text.ExternalNotFoundOption.TOSLinkText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundTOSConfirmAnd, existingText.ExternalUserNotFoundTOSConfirmAnd, text.ExternalNotFoundOption.TOSConfirmAnd, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
event = c.createCustomLoginTextEvent(ctx, agg, domain.LoginKeyExternalNotFoundPrivacyLinkText, existingText.ExternalUserNotFoundPrivacyLinkText, text.ExternalNotFoundOption.PrivacyLinkText, text.Language, defaultText)
if event != nil {
events = append(events, event)
}
return events
}
+218 -3
View File
@@ -161,9 +161,10 @@ type CustomLoginTextReadModel struct {
PasswordlessRegistrationNotSupported string
PasswordlessRegistrationErrorRetry string
PasswordlessRegistrationDoneTitle string
PasswordlessRegistrationDoneDescription string
PasswordlessRegistrationDoneNextButtonText string
PasswordlessRegistrationDoneTitle string
PasswordlessRegistrationDoneDescription string
PasswordlessRegistrationDoneNextButtonText string
PasswordlessRegistrationDoneCancelButtonText string
PasswordChangeTitle string
PasswordChangeDescription string
@@ -207,6 +208,25 @@ type CustomLoginTextReadModel struct {
RegistrationUserNextButtonText string
RegistrationUserBackButtonText string
ExternalRegistrationUserOverviewTitle string
ExternalRegistrationUserOverviewDescription string
ExternalRegistrationUserOverviewEmailLabel string
ExternalRegistrationUserOverviewUsernameLabel string
ExternalRegistrationUserOverviewFirstnameLabel string
ExternalRegistrationUserOverviewLastnameLabel string
ExternalRegistrationUserOverviewNicknameLabel string
ExternalRegistrationUserOverviewLanguageLabel string
ExternalRegistrationUserOverviewPhoneLabel string
ExternalRegistrationUserOverviewTOSAndPrivacyLabel string
ExternalRegistrationUserOverviewTOSConfirm string
ExternalRegistrationUserOverviewTOSLink string
ExternalRegistrationUserOverviewTOSLinkText string
ExternalRegistrationUserOverviewTOSConfirmAnd string
ExternalRegistrationUserOverviewPrivacyLink string
ExternalRegistrationUserOverviewPrivacyLinkText string
ExternalRegistrationUserOverviewBackButtonText string
ExternalRegistrationUserOverviewNextButtonText string
RegisterOrgTitle string
RegisterOrgDescription string
RegisterOrgOrgNameLabel string
@@ -232,6 +252,11 @@ type CustomLoginTextReadModel struct {
ExternalUserNotFoundDescription string
ExternalUserNotFoundLinkButtonText string
ExternalUserNotFoundAutoRegisterButtonText string
ExternalUserNotFoundTOSAndPrivacyLabel string
ExternalUserNotFoundTOSConfirm string
ExternalUserNotFoundTOSLinkText string
ExternalUserNotFoundTOSConfirmAnd string
ExternalUserNotFoundPrivacyLinkText string
SuccessLoginTitle string
SuccessLoginAutoRedirectDescription string
@@ -364,6 +389,10 @@ func (wm *CustomLoginTextReadModel) Reduce() error {
wm.handleRegistrationUserScreenSetEvent(e)
continue
}
if strings.HasPrefix(e.Key, domain.LoginKeyExternalRegistrationUserOverview) {
wm.handleExternalRegistrationUserOverviewScreenSetEvent(e)
continue
}
if strings.HasPrefix(e.Key, domain.LoginKeyRegistrationOrg) {
wm.handleRegistrationOrgScreenSetEvent(e)
continue
@@ -500,6 +529,10 @@ func (wm *CustomLoginTextReadModel) Reduce() error {
wm.handleRegistrationUserScreenRemoveEvent(e)
continue
}
if strings.HasPrefix(e.Key, domain.LoginKeyExternalRegistrationUserOverview) {
wm.handleExternalRegistrationUserOverviewScreenRemoveEvent(e)
continue
}
if strings.HasPrefix(e.Key, domain.LoginKeyRegistrationOrg) {
wm.handleRegistrationOrgScreenRemoveEvent(e)
continue
@@ -1652,6 +1685,10 @@ func (wm *CustomLoginTextReadModel) handlePasswordlessRegistrationDoneScreenSetE
wm.PasswordlessRegistrationDoneNextButtonText = e.Text
return
}
if e.Key == domain.LoginKeyPasswordlessRegistrationDoneCancelButtonText {
wm.PasswordlessRegistrationDoneCancelButtonText = e.Text
return
}
}
func (wm *CustomLoginTextReadModel) handlePasswordlessRegistrationDoneScreenRemoveEvent(e *policy.CustomTextRemovedEvent) {
@@ -1667,6 +1704,10 @@ func (wm *CustomLoginTextReadModel) handlePasswordlessRegistrationDoneScreenRemo
wm.PasswordlessRegistrationDoneNextButtonText = ""
return
}
if e.Key == domain.LoginKeyPasswordlessRegistrationDoneCancelButtonText {
wm.PasswordlessRegistrationDoneCancelButtonText = ""
return
}
}
func (wm *CustomLoginTextReadModel) handlePasswordChangeScreenSetEvent(e *policy.CustomTextSetEvent) {
@@ -1904,6 +1945,73 @@ func (wm *CustomLoginTextReadModel) handleRegistrationUserScreenSetEvent(e *poli
}
}
func (wm *CustomLoginTextReadModel) handleExternalRegistrationUserOverviewScreenSetEvent(e *policy.CustomTextSetEvent) {
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTitle {
wm.ExternalRegistrationUserOverviewTitle = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewDescription {
wm.ExternalRegistrationUserOverviewDescription = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewEmailLabel {
wm.ExternalRegistrationUserOverviewEmailLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewUsernameLabel {
wm.ExternalRegistrationUserOverviewUsernameLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewFirstnameLabel {
wm.ExternalRegistrationUserOverviewFirstnameLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewLastnameLabel {
wm.ExternalRegistrationUserOverviewLastnameLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewNicknameLabel {
wm.ExternalRegistrationUserOverviewNicknameLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewLanguageLabel {
wm.ExternalRegistrationUserOverviewLanguageLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewPhoneLabel {
wm.ExternalRegistrationUserOverviewPhoneLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSAndPrivacyLabel {
wm.ExternalRegistrationUserOverviewTOSAndPrivacyLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSConfirm {
wm.ExternalRegistrationUserOverviewTOSConfirm = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSLinkText {
wm.ExternalRegistrationUserOverviewTOSLinkText = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSConfirmAnd {
wm.ExternalRegistrationUserOverviewTOSConfirmAnd = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewPrivacyLinkText {
wm.ExternalRegistrationUserOverviewPrivacyLinkText = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewBackButtonText {
wm.ExternalRegistrationUserOverviewBackButtonText = e.Text
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewNextButtonText {
wm.ExternalRegistrationUserOverviewNextButtonText = e.Text
return
}
}
func (wm *CustomLoginTextReadModel) handleRegistrationUserScreenRemoveEvent(e *policy.CustomTextRemovedEvent) {
if e.Key == domain.LoginKeyRegistrationUserTitle {
wm.RegistrationUserTitle = ""
@@ -1979,6 +2087,73 @@ func (wm *CustomLoginTextReadModel) handleRegistrationUserScreenRemoveEvent(e *p
}
}
func (wm *CustomLoginTextReadModel) handleExternalRegistrationUserOverviewScreenRemoveEvent(e *policy.CustomTextRemovedEvent) {
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTitle {
wm.ExternalRegistrationUserOverviewTitle = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewDescription {
wm.ExternalRegistrationUserOverviewDescription = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewEmailLabel {
wm.ExternalRegistrationUserOverviewEmailLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewUsernameLabel {
wm.ExternalRegistrationUserOverviewUsernameLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewFirstnameLabel {
wm.ExternalRegistrationUserOverviewFirstnameLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewLastnameLabel {
wm.ExternalRegistrationUserOverviewLastnameLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewNicknameLabel {
wm.ExternalRegistrationUserOverviewNicknameLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewLanguageLabel {
wm.ExternalRegistrationUserOverviewLanguageLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewPhoneLabel {
wm.ExternalRegistrationUserOverviewPhoneLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSAndPrivacyLabel {
wm.ExternalRegistrationUserOverviewTOSAndPrivacyLabel = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSConfirm {
wm.ExternalRegistrationUserOverviewTOSConfirm = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSLinkText {
wm.ExternalRegistrationUserOverviewTOSLinkText = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewTOSConfirmAnd {
wm.ExternalRegistrationUserOverviewTOSConfirmAnd = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewPrivacyLinkText {
wm.ExternalRegistrationUserOverviewPrivacyLinkText = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewBackButtonText {
wm.ExternalRegistrationUserOverviewBackButtonText = ""
return
}
if e.Key == domain.LoginKeyExternalRegistrationUserOverviewNextButtonText {
wm.ExternalRegistrationUserOverviewNextButtonText = ""
return
}
}
func (wm *CustomLoginTextReadModel) handleRegistrationOrgScreenSetEvent(e *policy.CustomTextSetEvent) {
if e.Key == domain.LoginKeyRegisterOrgTitle {
wm.RegisterOrgTitle = e.Text
@@ -2160,6 +2335,26 @@ func (wm *CustomLoginTextReadModel) handleExternalUserNotFoundScreenSetEvent(e *
wm.ExternalUserNotFoundAutoRegisterButtonText = e.Text
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSAndPrivacyLabel {
wm.ExternalUserNotFoundTOSAndPrivacyLabel = e.Text
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSConfirm {
wm.ExternalUserNotFoundTOSConfirm = e.Text
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSLinkText {
wm.ExternalUserNotFoundTOSLinkText = e.Text
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSConfirmAnd {
wm.ExternalUserNotFoundTOSConfirmAnd = e.Text
return
}
if e.Key == domain.LoginKeyExternalNotFoundPrivacyLinkText {
wm.ExternalUserNotFoundPrivacyLinkText = e.Text
return
}
}
func (wm *CustomLoginTextReadModel) handleExternalUserNotFoundScreenRemoveEvent(e *policy.CustomTextRemovedEvent) {
@@ -2179,6 +2374,26 @@ func (wm *CustomLoginTextReadModel) handleExternalUserNotFoundScreenRemoveEvent(
wm.ExternalUserNotFoundAutoRegisterButtonText = ""
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSAndPrivacyLabel {
wm.ExternalUserNotFoundTOSAndPrivacyLabel = ""
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSLinkText {
wm.ExternalUserNotFoundTOSLinkText = ""
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSConfirm {
wm.ExternalUserNotFoundTOSConfirm = ""
return
}
if e.Key == domain.LoginKeyExternalNotFoundTOSConfirmAnd {
wm.ExternalUserNotFoundTOSConfirmAnd = ""
return
}
if e.Key == domain.LoginKeyExternalNotFoundPrivacyLinkText {
wm.ExternalUserNotFoundPrivacyLinkText = ""
return
}
}
func (wm *CustomLoginTextReadModel) handleSuccessLoginScreenSetEvent(e *policy.CustomTextSetEvent) {
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -206,7 +206,7 @@ func (c *Commands) createHuman(ctx context.Context, orgID string, human *domain.
events = append(events, event)
}
if human.IsInitialState(passwordless) {
if human.IsInitialState(passwordless, externalIDP != nil) {
initCode, err := domain.NewInitUserCode(c.initializeUserCode)
if err != nil {
return nil, nil, err