forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[main] Login email before username (grafana#57400)
* Swap order of login fields * Validate email field before validating the username field. Co-authored-by: linoman <[email protected]>
- Loading branch information
Showing
2 changed files
with
62 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,6 +202,47 @@ func TestIntegrationUserDataAccess(t *testing.T) { | |
require.Error(t, err) | ||
}) | ||
|
||
t.Run("GetByLogin - user2 uses user1.email as login", func(t *testing.T) { | ||
// create user_1 | ||
user1 := &user.User{ | ||
Email: "[email protected]", | ||
Name: "user_1", | ||
Login: "user_1", | ||
Password: "user_1_password", | ||
Created: time.Now(), | ||
Updated: time.Now(), | ||
IsDisabled: true, | ||
} | ||
_, err := userStore.Insert(context.Background(), user1) | ||
require.Nil(t, err) | ||
|
||
// create user_2 | ||
user2 := &user.User{ | ||
Email: "[email protected]", | ||
Name: "user_2", | ||
Login: "[email protected]", | ||
Password: "user_2_password", | ||
Created: time.Now(), | ||
Updated: time.Now(), | ||
IsDisabled: true, | ||
} | ||
_, err = userStore.Insert(context.Background(), user2) | ||
require.Nil(t, err) | ||
|
||
// query user database for user_1 email | ||
query := user.GetUserByLoginQuery{LoginOrEmail: "[email protected]"} | ||
result, err := userStore.GetByLogin(context.Background(), &query) | ||
require.Nil(t, err) | ||
|
||
// expect user_1 as result | ||
require.Equal(t, user1.Email, result.Email) | ||
require.Equal(t, user1.Login, result.Login) | ||
require.Equal(t, user1.Name, result.Name) | ||
require.NotEqual(t, user2.Email, result.Email) | ||
require.NotEqual(t, user2.Login, result.Login) | ||
require.NotEqual(t, user2.Name, result.Name) | ||
}) | ||
|
||
ss.Cfg.CaseInsensitiveLogin = false | ||
}) | ||
|
||
|