From 2c95fd41155e6c419145ed57acfeb32b8b59f3d6 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 11 Feb 2025 09:42:35 +0100 Subject: [PATCH] [bugfix] Suggest lowercase username when creating via OIDC (#3780) --- internal/api/auth/callback.go | 8 +++++++- web/template/finalize.tmpl | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/api/auth/callback.go b/internal/api/auth/callback.go index 37c257229..2dc36fac8 100644 --- a/internal/api/auth/callback.go +++ b/internal/api/auth/callback.go @@ -145,12 +145,18 @@ func (m *Module) CallbackGETHandler(c *gin.Context) { return } + // Since we require lowercase usernames at this point, lowercase the one + // from the claims and use this to autofill the form with a suggestion. + // + // Pending https://github.com/superseriousbusiness/gotosocial/issues/1813 + suggestedUsername := strings.ToLower(claims.PreferredUsername) + page := apiutil.WebPage{ Template: "finalize.tmpl", Instance: instance, Extra: map[string]any{ "name": claims.Name, - "preferredUsername": claims.PreferredUsername, + "suggestedUsername": suggestedUsername, }, } diff --git a/web/template/finalize.tmpl b/web/template/finalize.tmpl index 861dc635f..8b63e0929 100644 --- a/web/template/finalize.tmpl +++ b/web/template/finalize.tmpl @@ -42,7 +42,7 @@ placeholder="Please enter your desired username" pattern="^[a-z0-9_]{1,64}$" title="lowercase a-z, numbers, and underscores; max 64 characters" - value="{{- .preferredUsername -}}" + value="{{- .suggestedUsername -}}" >