mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-07 15:47:40 +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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
errs "errors"
|
errs "errors"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
sq "github.com/Masterminds/squirrel"
|
sq "github.com/Masterminds/squirrel"
|
||||||
@ -179,6 +180,10 @@ var (
|
|||||||
name: "loginnames",
|
name: "loginnames",
|
||||||
table: userLoginNamesTable,
|
table: userLoginNamesTable,
|
||||||
}
|
}
|
||||||
|
userLoginNamesLowerListCol = Column{
|
||||||
|
name: "loginnames_lower",
|
||||||
|
table: userLoginNamesTable,
|
||||||
|
}
|
||||||
userPreferredLoginNameTable = loginNameTable.setAlias("preferred_login_name")
|
userPreferredLoginNameTable = loginNameTable.setAlias("preferred_login_name")
|
||||||
userPreferredLoginNameUserIDCol = LoginNameUserIDCol.setTable(userPreferredLoginNameTable)
|
userPreferredLoginNameUserIDCol = LoginNameUserIDCol.setTable(userPreferredLoginNameTable)
|
||||||
userPreferredLoginNameCol = LoginNameNameCol.setTable(userPreferredLoginNameTable)
|
userPreferredLoginNameCol = LoginNameNameCol.setTable(userPreferredLoginNameTable)
|
||||||
@ -642,7 +647,7 @@ func NewUserPreferredLoginNameSearchQuery(value string, comparison TextCompariso
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewUserLoginNamesSearchQuery(value string) (SearchQuery, error) {
|
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) {
|
func NewUserLoginNameExistsQuery(value string, comparison TextComparison) (SearchQuery, error) {
|
||||||
@ -677,6 +682,7 @@ func prepareLoginNamesQuery() (string, []interface{}, error) {
|
|||||||
return sq.Select(
|
return sq.Select(
|
||||||
userLoginNamesUserIDCol.identifier(),
|
userLoginNamesUserIDCol.identifier(),
|
||||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+")::TEXT[] AS "+userLoginNamesListCol.name,
|
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+")::TEXT[] AS "+userLoginNamesListCol.name,
|
||||||
|
"ARRAY_AGG(LOWER("+userLoginNamesNameCol.identifier()+"))::TEXT[] AS "+userLoginNamesLowerListCol.name,
|
||||||
userLoginNamesInstanceIDCol.identifier(),
|
userLoginNamesInstanceIDCol.identifier(),
|
||||||
userLoginNamesOwnerRemovedUserCol.identifier(),
|
userLoginNamesOwnerRemovedUserCol.identifier(),
|
||||||
userLoginNamesOwnerRemovedPolicyCol.identifier(),
|
userLoginNamesOwnerRemovedPolicyCol.identifier(),
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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` +
|
` 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`
|
` 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` +
|
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…
x
Reference in New Issue
Block a user