diff --git a/components/user.templ b/components/user.templ index b9f8377..c397fb2 100644 --- a/components/user.templ +++ b/components/user.templ @@ -1,12 +1,24 @@ package components import ( - "unicode" + "crypto/md5" + "fmt" + "strings" + "html/template" "github.com/zitadel/oidc/v3/pkg/oidc" openid "github.com/zitadel/zitadel-go/v3/pkg/authentication/oidc" ) +var GravatarTemplate = template.Must(template.New("gravatar").Parse("
")) + +func GetGravatarURL(email string, size uint) string { + email = strings.TrimSpace(strings.ToLower(email)) + hash := md5.Sum([]byte(email)) + gravatarURL := fmt.Sprintf("https://www.gravatar.com/avatar/%x?s=%d", hash, size) + return string(templ.URL(gravatarURL)) +} + templ User(authCtx *openid.UserInfoContext[*oidc.IDTokenClaims, *oidc.UserInfo]) {