Skip to content

Commit e2fb38e

Browse files
committed
fix(model): trim whitespace from name fields
• Ensures that name fields are clean and consistent • Prevents potential issues with empty or malformed names
1 parent d4c4e0d commit e2fb38e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

jwt/raw.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package jwt
22

3+
import "strings"
4+
35
type rawClaims struct {
46
RawAudiences interface{} `json:"aud"` // RawAudiences could be a []string or string depending on the serialization in IdP site
57
RawEmail string `json:"email,omitempty"`
@@ -15,23 +17,23 @@ type rawWebToken struct {
1517
}
1618

1719
func (r rawWebToken) getMail() (mail string) {
18-
mail = r.RawMail
20+
mail = strings.TrimSpace(r.RawMail)
1921
if mail == "" {
2022
mail = r.RawEmail
2123
}
2224
return
2325
}
2426

2527
func (r rawWebToken) getLastName() (lastName string) {
26-
lastName = r.LastName
28+
lastName = strings.TrimSpace(r.LastName)
2729
if lastName == "" {
2830
lastName = r.RawFamilyName
2931
}
3032
return
3133
}
3234

3335
func (r rawWebToken) getFirstName() (firstName string) {
34-
firstName = r.FirstName
36+
firstName = strings.TrimSpace(r.FirstName)
3537
if firstName == "" {
3638
firstName = r.RawGivenName
3739
}

0 commit comments

Comments
 (0)