Allow non-local users to change their username
parent
6eaebda1b5
commit
f851b5635c
|
@ -45,12 +45,6 @@ func Profile(ctx *context.Context) {
|
||||||
|
|
||||||
// HandleUsernameChange handle username changes from user settings and admin interface
|
// HandleUsernameChange handle username changes from user settings and admin interface
|
||||||
func HandleUsernameChange(ctx *context.Context, user *models.User, newName string) error {
|
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
|
// Check if user name has been changed
|
||||||
if user.LowerName != strings.ToLower(newName) {
|
if user.LowerName != strings.ToLower(newName) {
|
||||||
if err := models.ChangeUserName(user, newName); err != nil {
|
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-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>
|
<span class="text red hide" id="name-change-redirect-prompt"> {{.i18n.Tr "settings.change_username_redirect_prompt"}}</span>
|
||||||
</label>
|
</label>
|
||||||
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" autofocus required {{if or (not .SignedUser.IsLocal) .IsReverseProxy}}disabled{{end}}>
|
<input id="username" name="name" value="{{.SignedUser.Name}}" data-name="{{.SignedUser.Name}}" autofocus required {{if .IsReverseProxy}}disabled{{end}}>
|
||||||
{{if or (not .SignedUser.IsLocal) .IsReverseProxy}}
|
{{if .IsReverseProxy}}
|
||||||
<p class="help text blue">{{$.i18n.Tr "settings.password_username_disabled"}}</p>
|
<p class="help text blue">{{$.i18n.Tr "settings.password_username_disabled"}}</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue