mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Auth: Prevent duplicate usernames when renaming accounts #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -212,7 +212,26 @@ func TestUser_Create(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestUser_SetName(t *testing.T) {
|
||||
func TestUser_UpdateUsername(t *testing.T) {
|
||||
t.Run("Exists", func(t *testing.T) {
|
||||
var m = User{
|
||||
ID: 2,
|
||||
UserName: "foo",
|
||||
UserRole: acl.RoleAdmin.String(),
|
||||
DisplayName: "Admin",
|
||||
SuperAdmin: false,
|
||||
CanLogin: true,
|
||||
}
|
||||
|
||||
if err := m.UpdateUsername("admin"); err == nil {
|
||||
t.Fatal("error expected")
|
||||
} else {
|
||||
t.Logf("expected errror: %s", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestUser_SetUsername(t *testing.T) {
|
||||
t.Run("photoprism", func(t *testing.T) {
|
||||
m := FindUserByName("admin")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user