mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix: login name case insensitive (#5032)
checks for login names case insensitive during login
This commit is contained in:
parent
1bf1f335dc
commit
71bd19d690
@ -53,7 +53,7 @@ func (v *View) UserByLoginNameAndResourceOwner(loginName, resourceOwner, instanc
|
||||
}
|
||||
|
||||
func (v *View) UserByEmail(email, instanceID string) (*model.UserView, error) {
|
||||
emailQuery, err := query.NewUserVerifiedEmailSearchQuery(email, query.TextEquals)
|
||||
emailQuery, err := query.NewUserVerifiedEmailSearchQuery(email, query.TextEqualsIgnoreCase)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
errs "errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
@ -179,6 +180,10 @@ var (
|
||||
name: "loginnames",
|
||||
table: userLoginNamesTable,
|
||||
}
|
||||
userLoginNamesLowerListCol = Column{
|
||||
name: "loginnames_lower",
|
||||
table: userLoginNamesTable,
|
||||
}
|
||||
userPreferredLoginNameTable = loginNameTable.setAlias("preferred_login_name")
|
||||
userPreferredLoginNameUserIDCol = LoginNameUserIDCol.setTable(userPreferredLoginNameTable)
|
||||
userPreferredLoginNameCol = LoginNameNameCol.setTable(userPreferredLoginNameTable)
|
||||
@ -642,7 +647,7 @@ func NewUserPreferredLoginNameSearchQuery(value string, comparison TextCompariso
|
||||
}
|
||||
|
||||
func NewUserLoginNamesSearchQuery(value string) (SearchQuery, error) {
|
||||
return NewTextQuery(userLoginNamesListCol, value, TextListContains)
|
||||
return NewTextQuery(userLoginNamesLowerListCol, strings.ToLower(value), TextListContains)
|
||||
}
|
||||
|
||||
func NewUserLoginNameExistsQuery(value string, comparison TextComparison) (SearchQuery, error) {
|
||||
@ -677,6 +682,7 @@ func prepareLoginNamesQuery() (string, []interface{}, error) {
|
||||
return sq.Select(
|
||||
userLoginNamesUserIDCol.identifier(),
|
||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+")::TEXT[] AS "+userLoginNamesListCol.name,
|
||||
"ARRAY_AGG(LOWER("+userLoginNamesNameCol.identifier()+"))::TEXT[] AS "+userLoginNamesLowerListCol.name,
|
||||
userLoginNamesInstanceIDCol.identifier(),
|
||||
userLoginNamesOwnerRemovedUserCol.identifier(),
|
||||
userLoginNamesOwnerRemovedPolicyCol.identifier(),
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
loginNamesQuery = `SELECT login_names.user_id, ARRAY_AGG(login_names.login_name)::TEXT[] AS loginnames, login_names.instance_id, login_names.user_owner_removed, login_names.policy_owner_removed, login_names.domain_owner_removed` +
|
||||
loginNamesQuery = `SELECT login_names.user_id, ARRAY_AGG(login_names.login_name)::TEXT[] AS loginnames, ARRAY_AGG(LOWER(login_names.login_name))::TEXT[] AS loginnames_lower, login_names.instance_id, login_names.user_owner_removed, login_names.policy_owner_removed, login_names.domain_owner_removed` +
|
||||
` FROM projections.login_names2 AS login_names` +
|
||||
` GROUP BY login_names.user_id, login_names.instance_id, login_names.user_owner_removed, login_names.policy_owner_removed, login_names.domain_owner_removed`
|
||||
preferredLoginNameQuery = `SELECT preferred_login_name.user_id, preferred_login_name.login_name, preferred_login_name.instance_id, preferred_login_name.user_owner_removed, preferred_login_name.policy_owner_removed, preferred_login_name.domain_owner_removed` +
|
||||
|
Loading…
Reference in New Issue
Block a user