Add option to disable username changing

This commit is contained in:
Jaakko Kantojärvi 2013-01-30 22:14:34 +02:00
parent 72e2a49819
commit de7012c4fb
4 changed files with 29 additions and 24 deletions

View file

@ -51,7 +51,9 @@ class ProfilesController < ApplicationController
end end
def update_username def update_username
@user.update_attributes(username: params[:user][:username]) if Gitlab.config.gitlab.username_changing_enabled
@user.update_attributes(username: params[:user][:username])
end
respond_to do |format| respond_to do |format|
format.js format.js

View file

@ -53,28 +53,29 @@
%fieldset.update-username - if Gitlab.config.gitlab.username_changing_enabled
%legend %fieldset.update-username
Username %legend
%small.cred.right Username
Changing your username can have unintended side effects! %small.cred.right
= form_for @user, url: update_username_profile_path, method: :put, remote: true do |f| Changing your username can have unintended side effects!
.padded = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f|
= f.label :username .padded
.input = f.label :username
= f.text_field :username, required: true .input
&nbsp; = f.text_field :username, required: true
%span.loading-gif.hide= image_tag "ajax_loader.gif" &nbsp;
%span.update-success.cgreen.hide %span.loading-gif.hide= image_tag "ajax_loader.gif"
%i.icon-ok %span.update-success.cgreen.hide
Saved %i.icon-ok
%span.update-failed.cred.hide Saved
%i.icon-remove %span.update-failed.cred.hide
Failed %i.icon-remove
%ul.cred Failed
%li It will change web url for personal projects. %ul.cred
%li It will change the git path to repositories for personal projects. %li It will change web url for personal projects.
.input %li It will change the git path to repositories for personal projects.
= f.submit 'Save username', class: "btn save-btn" .input
= f.submit 'Save username', class: "btn save-btn"

View file

@ -35,6 +35,7 @@ gitlab:
## Project settings ## Project settings
default_projects_limit: 10 default_projects_limit: 10
# signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled.
# username_changing_enabled: false # default: true - User can change her username/namespace
## Gravatar ## Gravatar
gravatar: gravatar:

View file

@ -53,6 +53,7 @@ Settings.gitlab['support_email'] ||= Settings.gitlab.email_from
Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)
Settings.gitlab['user'] ||= 'gitlab' Settings.gitlab['user'] ||= 'gitlab'
Settings.gitlab['signup_enabled'] ||= false Settings.gitlab['signup_enabled'] ||= false
Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil?
Settings['gravatar'] ||= Settingslogic.new({}) Settings['gravatar'] ||= Settingslogic.new({})
Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil? Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil?