Drop SCIM export userName email fallback
Email comes from identity when a profile matches; empty email only when the event has no profile row to join. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
@@ -30,7 +30,6 @@ import (
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/mail"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"go.probo.inc/probo/pkg/safecsv"
|
||||
)
|
||||
@@ -228,11 +227,6 @@ func scimEventCSVRow(
|
||||
) []string {
|
||||
profile := profilesByUserName[strings.ToLower(event.UserName)]
|
||||
|
||||
email := profile.email
|
||||
if email == "" {
|
||||
email = scimEmailFromUserName(event.UserName)
|
||||
}
|
||||
|
||||
return []string{
|
||||
organizationName,
|
||||
event.ID.String(),
|
||||
@@ -240,7 +234,7 @@ func scimEventCSVRow(
|
||||
event.Method,
|
||||
event.Path,
|
||||
event.UserName,
|
||||
email,
|
||||
profile.email,
|
||||
profile.fullName,
|
||||
strconv.Itoa(event.StatusCode),
|
||||
stringPtrValue(event.ErrorMessage),
|
||||
@@ -381,19 +375,6 @@ func uniqueNonEmptyStrings(values []string) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
func scimEmailFromUserName(userName string) string {
|
||||
userName = strings.TrimSpace(userName)
|
||||
if userName == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
if _, err := mail.ParseAddr(userName); err == nil {
|
||||
return userName
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func profileFullName(profile *coredata.MembershipProfile) string {
|
||||
if profile.FormattedName != nil && *profile.FormattedName != "" {
|
||||
return *profile.FormattedName
|
||||
|
||||
@@ -32,11 +32,3 @@ func TestUniqueNonEmptyStrings(t *testing.T) {
|
||||
got := uniqueNonEmptyStrings([]string{"a", "A", "", "b", "a"})
|
||||
assert.Equal(t, []string{"a", "b"}, got)
|
||||
}
|
||||
|
||||
func TestScimEmailFromUserName(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert.Equal(t, "user@example.com", scimEmailFromUserName("user@example.com"))
|
||||
assert.Equal(t, "", scimEmailFromUserName("not-an-email"))
|
||||
assert.Equal(t, "", scimEmailFromUserName(""))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user