@@ -238,6 +238,13 @@ func (s *EnvironmentService) CreateDemoOrganization(
238238 return nil , err
239239 }
240240
241+ // Demo organizations need both Google and Password authentication enabled
242+ authSettings := & environmentproto.AuthenticationSettings {
243+ EnabledTypes : []environmentproto.AuthenticationType {
244+ environmentproto .AuthenticationType_AUTHENTICATION_TYPE_GOOGLE ,
245+ environmentproto .AuthenticationType_AUTHENTICATION_TYPE_PASSWORD ,
246+ },
247+ }
241248 organization , err := s .createOrganizationMySQL (
242249 ctx ,
243250 req .Name ,
@@ -246,7 +253,7 @@ func (s *EnvironmentService) CreateDemoOrganization(
246253 req .Description ,
247254 false ,
248255 false ,
249- true , // Enable password auth for demo organizations
256+ authSettings ,
250257 localizer ,
251258 )
252259 if err != nil {
@@ -391,14 +398,20 @@ func (s *EnvironmentService) CreateOrganization(
391398 }
392399 name := strings .TrimSpace (req .Command .Name )
393400 urlCode := strings .TrimSpace (req .Command .UrlCode )
401+ // Default authentication settings: Google only
402+ defaultAuthSettings := & environmentproto.AuthenticationSettings {
403+ EnabledTypes : []environmentproto.AuthenticationType {
404+ environmentproto .AuthenticationType_AUTHENTICATION_TYPE_GOOGLE ,
405+ },
406+ }
394407 organization , err := domain .NewOrganization (
395408 name ,
396409 urlCode ,
397410 req .Command .OwnerEmail ,
398411 req .Command .Description ,
399412 req .Command .IsTrial ,
400413 req .Command .IsSystemAdmin ,
401- true , // Default password auth enabled for backward compatibility
414+ defaultAuthSettings ,
402415 )
403416 if err != nil {
404417 s .logger .Error (
@@ -496,7 +509,7 @@ func (s *EnvironmentService) createOrganizationNoCommand(
496509 req .Description ,
497510 req .IsTrial ,
498511 req .IsSystemAdmin ,
499- req .PasswordAuthenticationEnabled ,
512+ req .AuthenticationSettings ,
500513 localizer ,
501514 )
502515 if err != nil {
@@ -542,7 +555,7 @@ func (s *EnvironmentService) createOrganizationMySQL(
542555 description string ,
543556 isTrial bool ,
544557 isSystemAdmin bool ,
545- passwordAuthenticationEnabled bool ,
558+ authenticationSettings * environmentproto. AuthenticationSettings ,
546559 localizer locale.Localizer ,
547560) (* domain.Organization , error ) {
548561 organization , err := domain .NewOrganization (
@@ -552,7 +565,7 @@ func (s *EnvironmentService) createOrganizationMySQL(
552565 description ,
553566 isTrial ,
554567 isSystemAdmin ,
555- passwordAuthenticationEnabled ,
568+ authenticationSettings ,
556569 )
557570 if err != nil {
558571 s .logger .Error (
@@ -881,25 +894,12 @@ func (s *EnvironmentService) updateOrganizationNoCommand(
881894 return err
882895 }
883896 prevOwnerEmail = organization .OwnerEmail
884- // Convert boolean password auth to authentication settings
885- var authSettings * environmentproto.AuthenticationSettings
886- if req .PasswordAuthenticationEnabled != nil {
887- // Start with Google authentication always enabled
888- authTypes := []environmentproto.AuthenticationType {environmentproto .AuthenticationType_AUTHENTICATION_TYPE_GOOGLE }
889- // Add password auth if enabled
890- if req .PasswordAuthenticationEnabled .Value {
891- authTypes = append (authTypes , environmentproto .AuthenticationType_AUTHENTICATION_TYPE_PASSWORD )
892- }
893- authSettings = & environmentproto.AuthenticationSettings {
894- EnabledTypes : authTypes ,
895- }
896- }
897897
898898 updated , err := organization .Update (
899899 req .Name ,
900900 req .Description ,
901901 req .OwnerEmail ,
902- authSettings ,
902+ req . AuthenticationSettings ,
903903 )
904904 if err != nil {
905905 return err
0 commit comments