Commit e049e187 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #2991 from raphendyr/username_change_disablation

Add option to disable username changing
parents ea28519f ba65f291
...@@ -51,7 +51,9 @@ class ProfilesController < ApplicationController ...@@ -51,7 +51,9 @@ class ProfilesController < ApplicationController
end end
def update_username def update_username
@user.update_attributes(username: params[:user][:username]) if @user.can_change_username?
@user.update_attributes(username: params[:user][:username])
end
respond_to do |format| respond_to do |format|
format.js format.js
......
...@@ -234,6 +234,10 @@ class User < ActiveRecord::Base ...@@ -234,6 +234,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 > owned_projects.count projects_limit > owned_projects.count
end end
......
...@@ -53,29 +53,30 @@ ...@@ -53,29 +53,30 @@
%fieldset.update-username - if current_user.can_change_username?
%legend %fieldset.update-username
Username %legend
%small.cred.pull-right Username
Changing your username can have unintended side effects! %small.cred.pull-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 btn-save" .input
= f.submit 'Save username', class: "btn btn-save"
- if Gitlab.config.gitlab.signup_enabled - if Gitlab.config.gitlab.signup_enabled
%fieldset.remove-account %fieldset.remove-account
...@@ -83,4 +84,4 @@ ...@@ -83,4 +84,4 @@
Remove account Remove account
%small.cred.pull-right %small.cred.pull-right
Before removing the account you must remove all projects! Before removing the account you must remove all projects!
= link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove delete-key btn-small pull-right" = link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove delete-key btn-small pull-right"
\ No newline at end of file
...@@ -35,6 +35,7 @@ production: &base ...@@ -35,6 +35,7 @@ production: &base
## 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:
......
...@@ -57,6 +57,7 @@ Settings.gitlab['support_email'] ||= Settings.gitlab.email_from ...@@ -57,6 +57,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'] ||= 'git' Settings.gitlab['user'] ||= 'git'
Settings.gitlab['signup_enabled'] ||= false Settings.gitlab['signup_enabled'] ||= false
Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil?
# #
# Gravatar # Gravatar
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment