Move username change decision into user model
This commit is contained in:
parent
de7012c4fb
commit
fcffb4c381
3 changed files with 6 additions and 2 deletions
|
@ -51,7 +51,7 @@ class ProfilesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_username
|
def update_username
|
||||||
if Gitlab.config.gitlab.username_changing_enabled
|
if @user.can_change_username?
|
||||||
@user.update_attributes(username: params[:user][:username])
|
@user.update_attributes(username: params[:user][:username])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- if Gitlab.config.gitlab.username_changing_enabled
|
- if current_user.can_change_username?
|
||||||
%fieldset.update-username
|
%fieldset.update-username
|
||||||
%legend
|
%legend
|
||||||
Username
|
Username
|
||||||
|
|
Loading…
Add table
Reference in a new issue