Allow non-local users to change their username
This commit is contained in:
parent
6eaebda1b5
commit
f851b5635c
2 changed files with 2 additions and 8 deletions
|
@ -45,12 +45,6 @@ func Profile(ctx *context.Context) {
|
|||
|
||||
// HandleUsernameChange handle username changes from user settings and admin interface
|
||||
func HandleUsernameChange(ctx *context.Context, user *models.User, newName string) error {
|
||||
// Non-local users are not allowed to change their username.
|
||||
if !user.IsLocal() {
|
||||
ctx.Flash.Error(ctx.Tr("form.username_change_not_local_user"))
|
||||
return fmt.Errorf(ctx.Tr("form.username_change_not_local_user"))
|
||||
}
|
||||
|
||||
// Check if user name has been changed
|
||||
if user.LowerName != strings.ToLower(newName) {
|
||||
if err := models.ChangeUserName(user, newName); err != nil {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
<span class="text red hide" id="name-change-prompt"> {{.i18n.Tr "settings.change_username_prompt"}}</span>
|
||||
<span class="text red hide" id="name-change-redirect-prompt"> {{.i18n.Tr "settings.change_username_redirect_prompt"}}</span>
|
||||
</label>
|
||||
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" autofocus required {{if or (not .SignedUser.IsLocal) .IsReverseProxy}}disabled{{end}}>
|
||||
{{if or (not .SignedUser.IsLocal) .IsReverseProxy}}
|
||||
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" autofocus required {{if .IsReverseProxy}}disabled{{end}}>
|
||||
{{if .IsReverseProxy}}
|
||||
<p class="help text blue">{{$.i18n.Tr "settings.password_username_disabled"}}</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue