From a4f2542924e43a47d8d427510257d93d1fa3912d Mon Sep 17 00:00:00 2001 From: Umputun Date: Fri, 30 Apr 2021 12:00:24 -0500 Subject: [PATCH] allow admin email login with restricted names #964 --- backend/app/cmd/server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/app/cmd/server.go b/backend/app/cmd/server.go index 2a7899e1..ba1c2f07 100644 --- a/backend/app/cmd/server.go +++ b/backend/app/cmd/server.go @@ -932,8 +932,9 @@ func (s *ServerCommand) makeAuthenticator(ds *service.DataStore, avas avatar.Sto log.Printf("[WARN] can't read email for %s, %v", c.User.ID, err) } - // don't allow anonymous and email with admin's name - if strings.HasPrefix(c.User.ID, "anonymous_") || strings.HasPrefix(c.User.ID, "email_") { + // don't allow anonymous and email with admins names + // exclude admin from impersonation detection over email, it prevents a valid admin to login with RestrictedNames + if strings.HasPrefix(c.User.ID, "anonymous_") || (strings.HasPrefix(c.User.ID, "email_") && !c.User.IsAdmin()) { for _, a := range s.RestrictedNames { if strings.EqualFold(strings.TrimSpace(c.User.Name), a) { c.User.SetBoolAttr("blocked", true)