Requester: Remove duplicated function (#97038)

* Remove duplicated function

* Remove GetDisplayName from interface

* Use GetName
This commit is contained in:
Karl Persson
2024-11-26 15:29:31 +01:00
committed by GitHub
parent 6d04023aa6
commit 76f052e8de
12 changed files with 26 additions and 69 deletions
+7 -21
View File
@@ -22,7 +22,6 @@ type StaticRequester struct {
OrgRole RoleType
Login string
Name string
DisplayName string
Email string
EmailVerified bool
AuthID string
@@ -89,7 +88,13 @@ func (u *StaticRequester) GetGroups() []string {
// GetName implements Requester.
func (u *StaticRequester) GetName() string {
return u.DisplayName
if u.Name != "" {
return u.Name
}
if u.Login != "" {
return u.Login
}
return u.Email
}
func (u *StaticRequester) HasRole(role RoleType) bool {
@@ -211,25 +216,6 @@ func (u *StaticRequester) GetCacheKey() string {
return u.CacheKey
}
// GetDisplayName returns the display name of the active entity
// The display name is the name if it is set, otherwise the login or email
func (u *StaticRequester) GetDisplayName() string {
if u.DisplayName != "" {
return u.DisplayName
}
if u.Name != "" {
return u.Name
}
if u.Login != "" {
return u.Login
}
return u.Email
}
func (u *StaticRequester) GetIDToken() string {
return u.IDToken
}
func (u *StaticRequester) GetIDClaims() *authnlib.Claims[authnlib.IDTokenClaims] {
return u.IDTokenClaims
}