Merge pull request #2888 from raphendyr/username_changing_disabled

Add option to disable username changing
This commit is contained in:
Dmitriy Zaporozhets 2013-02-13 05:04:50 -08:00
commit db958e5997
5 changed files with 33 additions and 24 deletions

View file

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

View file

@ -215,6 +215,10 @@ class User < ActiveRecord::Base
keys.count == 0 keys.count == 0
end end
def can_change_username?
Gitlab.config.gitlab.username_changing_enabled
end
def can_create_project? def can_create_project?
projects_limit > personal_projects.count projects_limit > personal_projects.count
end end

View file

@ -53,7 +53,8 @@
%fieldset.update-username - if current_user.can_change_username?
%fieldset.update-username
%legend %legend
Username Username
%small.cred.right %small.cred.right

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?