mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 17:57:33 +00:00
fix: allow login by email case-insensitive (#7578)
A customer noted that the login by email was case-sensitive, which differs to the handling of the loginname. This PR changes the email check to be case-insensitive (which it was already in same parts) and improve the search for this as well.
This commit is contained in:
27
cmd/setup/25.go
Normal file
27
cmd/setup/25.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed 25.sql
|
||||
addLowerFieldsToVerifiedEmail string
|
||||
)
|
||||
|
||||
type AddLowerFieldsToVerifiedEmail struct {
|
||||
dbClient *database.DB
|
||||
}
|
||||
|
||||
func (mig *AddLowerFieldsToVerifiedEmail) Execute(ctx context.Context, _ eventstore.Event) error {
|
||||
_, err := mig.dbClient.ExecContext(ctx, addLowerFieldsToVerifiedEmail)
|
||||
return err
|
||||
}
|
||||
|
||||
func (mig *AddLowerFieldsToVerifiedEmail) String() string {
|
||||
return "25_add_lower_fields_to_verified_email"
|
||||
}
|
2
cmd/setup/25.sql
Normal file
2
cmd/setup/25.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE IF EXISTS projections.users10_notifications ADD COLUMN IF NOT EXISTS verified_email_lower TEXT GENERATED ALWAYS AS (lower(verified_email)) STORED;
|
||||
CREATE INDEX IF NOT EXISTS users10_notifications_email_search ON projections.users10_notifications (instance_id, verified_email_lower);
|
@@ -103,6 +103,7 @@ type Steps struct {
|
||||
s22ActiveInstancesIndex *ActiveInstanceEvents
|
||||
s23CorrectGlobalUniqueConstraints *CorrectGlobalUniqueConstraints
|
||||
s24AddActorToAuthTokens *AddActorToAuthTokens
|
||||
s25AddLowerFieldsToVerifiedEmail *AddLowerFieldsToVerifiedEmail
|
||||
}
|
||||
|
||||
func MustNewSteps(v *viper.Viper) *Steps {
|
||||
|
@@ -137,6 +137,7 @@ func Setup(config *Config, steps *Steps, masterKey string) {
|
||||
steps.s22ActiveInstancesIndex = &ActiveInstanceEvents{dbClient: queryDBClient}
|
||||
steps.s23CorrectGlobalUniqueConstraints = &CorrectGlobalUniqueConstraints{dbClient: esPusherDBClient}
|
||||
steps.s24AddActorToAuthTokens = &AddActorToAuthTokens{dbClient: queryDBClient}
|
||||
steps.s25AddLowerFieldsToVerifiedEmail = &AddLowerFieldsToVerifiedEmail{dbClient: esPusherDBClient}
|
||||
|
||||
err = projection.Create(ctx, projectionDBClient, eventstoreClient, config.Projections, nil, nil, nil)
|
||||
logging.OnError(err).Fatal("unable to start projections")
|
||||
@@ -186,6 +187,7 @@ func Setup(config *Config, steps *Steps, masterKey string) {
|
||||
for _, step := range []migration.Migration{
|
||||
steps.s18AddLowerFieldsToLoginNames,
|
||||
steps.s21AddBlockFieldToLimits,
|
||||
steps.s25AddLowerFieldsToVerifiedEmail,
|
||||
} {
|
||||
mustExecuteMigration(ctx, eventstoreClient, step, "migration failed")
|
||||
}
|
||||
|
Reference in New Issue
Block a user