[bugfix] Suggest lowercase username when creating via OIDC (#3780)

This commit is contained in:
tobi 2025-02-11 09:42:35 +01:00 committed by GitHub
parent 4ac5447ad6
commit 2c95fd4115
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -145,12 +145,18 @@ func (m *Module) CallbackGETHandler(c *gin.Context) {
return 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{ page := apiutil.WebPage{
Template: "finalize.tmpl", Template: "finalize.tmpl",
Instance: instance, Instance: instance,
Extra: map[string]any{ Extra: map[string]any{
"name": claims.Name, "name": claims.Name,
"preferredUsername": claims.PreferredUsername, "suggestedUsername": suggestedUsername,
}, },
} }

View file

@ -42,7 +42,7 @@
placeholder="Please enter your desired username" placeholder="Please enter your desired username"
pattern="^[a-z0-9_]{1,64}$" pattern="^[a-z0-9_]{1,64}$"
title="lowercase a-z, numbers, and underscores; max 64 characters" title="lowercase a-z, numbers, and underscores; max 64 characters"
value="{{- .preferredUsername -}}" value="{{- .suggestedUsername -}}"
> >
</div> </div>
<input type="hidden" name="name" value="{{- .name -}}"> <input type="hidden" name="name" value="{{- .name -}}">