Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJaakko Kantojärvi <jaakko@n-1.fi>2013-01-31 00:14:34 +0400
committerJaakko Kantojärvi <jaakko@n-1.fi>2013-02-14 19:58:56 +0400
commitba65f2910b1285217326028655de057a702572af (patch)
tree391cce80e2111d77a2695e99a518746ffe75a0f5 /app
parent04186e9797209ff5a9b2fd4025d458a6e2223f62 (diff)
Add option to disable username changing
This option allows to disable users from changing their username. This is very usefull in environments using strong internal authentication methods like ldap, pam or shibboleth. You can allow users to change theyr username in these environments, but then new users (users loging in first time) is blocked from gitlab is her username exists.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/profiles_controller.rb4
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/profiles/account.html.haml49
3 files changed, 32 insertions, 25 deletions
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index 1d1efb16f04..051a6664519 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -51,7 +51,9 @@ class ProfilesController < ApplicationController
end
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|
format.js
diff --git a/app/models/user.rb b/app/models/user.rb
index 10af9b8c165..7c3a876d73e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -234,6 +234,10 @@ class User < ActiveRecord::Base
keys.count == 0
end
+ def can_change_username?
+ Gitlab.config.gitlab.username_changing_enabled
+ end
+
def can_create_project?
projects_limit > personal_projects.count
end
diff --git a/app/views/profiles/account.html.haml b/app/views/profiles/account.html.haml
index 5465d1f96e9..5b6c298df4a 100644
--- a/app/views/profiles/account.html.haml
+++ b/app/views/profiles/account.html.haml
@@ -53,29 +53,30 @@
-%fieldset.update-username
- %legend
- Username
- %small.cred.pull-right
- Changing your username can have unintended side effects!
- = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f|
- .padded
- = f.label :username
- .input
- = f.text_field :username, required: true
- &nbsp;
- %span.loading-gif.hide= image_tag "ajax_loader.gif"
- %span.update-success.cgreen.hide
- %i.icon-ok
- Saved
- %span.update-failed.cred.hide
- %i.icon-remove
- Failed
- %ul.cred
- %li It will change web url for personal projects.
- %li It will change the git path to repositories for personal projects.
- .input
- = f.submit 'Save username', class: "btn btn-save"
+- if current_user.can_change_username?
+ %fieldset.update-username
+ %legend
+ Username
+ %small.cred.pull-right
+ Changing your username can have unintended side effects!
+ = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f|
+ .padded
+ = f.label :username
+ .input
+ = f.text_field :username, required: true
+ &nbsp;
+ %span.loading-gif.hide= image_tag "ajax_loader.gif"
+ %span.update-success.cgreen.hide
+ %i.icon-ok
+ Saved
+ %span.update-failed.cred.hide
+ %i.icon-remove
+ Failed
+ %ul.cred
+ %li It will change web url for personal projects.
+ %li It will change the git path to repositories for personal projects.
+ .input
+ = f.submit 'Save username', class: "btn btn-save"
- if Gitlab.config.gitlab.signup_enabled
%fieldset.remove-account
@@ -83,4 +84,4 @@
Remove account
%small.cred.pull-right
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" \ No newline at end of file
+ = 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"