-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'admin-edit-identities' into 'master'
Admin can see, edit and remove user identities Related to #1415 and https://dev.gitlab.org/gitlab/gitlabhq/issues/2224 Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> See merge request !843
- Loading branch information
Showing
16 changed files
with
424 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class Admin::IdentitiesController < Admin::ApplicationController | ||
before_action :user | ||
before_action :identity, except: :index | ||
|
||
def index | ||
@identities = @user.identities | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @identity.update_attributes(identity_params) | ||
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.' | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
if @identity.destroy | ||
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully removed.' | ||
else | ||
redirect_to admin_user_identities_path(@user), alert: 'Failed to remove user identity.' | ||
end | ||
end | ||
|
||
protected | ||
|
||
def user | ||
@user ||= User.find_by!(username: params[:user_id]) | ||
end | ||
|
||
def identity | ||
@identity ||= user.identities.find(params[:id]) | ||
end | ||
|
||
def identity_params | ||
params.require(:identity).permit(:provider, :extern_uid) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
= form_for [:admin, @user, @identity], html: { class: 'form-horizontal fieldset-form' } do |f| | ||
- if @identity.errors.any? | ||
#error_explanation | ||
.alert.alert-danger | ||
- @identity.errors.full_messages.each do |msg| | ||
%p= msg | ||
|
||
.form-group | ||
= f.label :provider, class: 'control-label' | ||
.col-sm-10 | ||
= f.select :provider, Gitlab::OAuth::Provider.names, { allow_blank: false }, class: 'form-control' | ||
.form-group | ||
= f.label :extern_uid, "Identifier", class: 'control-label' | ||
.col-sm-10 | ||
= f.text_field :extern_uid, required: true, class: 'form-control', required: true | ||
|
||
.form-actions | ||
= f.submit 'Save changes', class: "btn btn-save" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%tr | ||
%td | ||
= identity.provider | ||
%td | ||
= identity.extern_uid | ||
%td | ||
= link_to edit_admin_user_identity_path(@user, identity), class: 'btn btn-xs btn-grouped' do | ||
Edit | ||
= link_to [:admin, @user, identity], method: :delete, | ||
class: 'btn btn-xs btn-danger', | ||
data: { confirm: "Are you sure you want to remove this identity?" } do | ||
Delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- page_title "Edit", @identity.provider, "Identities", @user.name, "Users" | ||
%h3.page-title | ||
Edit identity for #{@user.name} | ||
%hr | ||
|
||
= render 'form' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- page_title "Identities", @user.name, "Users" | ||
= render 'admin/users/head' | ||
|
||
- if @identities.present? | ||
%table.table | ||
%thead | ||
%tr | ||
%th Provider | ||
%th Identifier | ||
%th | ||
= render @identities | ||
- else | ||
%h4 This user has no identities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
%h3.page-title | ||
= @user.name | ||
- if @user.blocked? | ||
%span.cred (Blocked) | ||
- if @user.admin | ||
%span.cred (Admin) | ||
|
||
.pull-right | ||
= link_to edit_admin_user_path(@user), class: "btn btn-grouped" do | ||
%i.fa.fa-pencil-square-o | ||
Edit | ||
%hr | ||
%ul.nav.nav-tabs | ||
= nav_link(path: 'users#show') do | ||
= link_to "Account", admin_user_path(@user) | ||
= nav_link(path: 'users#groups') do | ||
= link_to "Groups", groups_admin_user_path(@user) | ||
= nav_link(path: 'users#projects') do | ||
= link_to "Projects", projects_admin_user_path(@user) | ||
= nav_link(path: 'users#keys') do | ||
= link_to "SSH keys", keys_admin_user_path(@user) | ||
= nav_link(controller: :identities) do | ||
= link_to "Identities", admin_user_identities_path(@user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- page_title "Groups", @user.name, "Users" | ||
= render 'admin/users/head' | ||
|
||
- if @user.group_members.present? | ||
.panel.panel-default | ||
.panel-heading Groups: | ||
%ul.well-list | ||
- @user.group_members.each do |group_member| | ||
- group = group_member.group | ||
%li.group_member | ||
%span{class: ("list-item-name" unless group_member.owner?)} | ||
%strong= link_to group.name, admin_group_path(group) | ||
.pull-right | ||
%span.light= group_member.human_access | ||
- unless group_member.owner? | ||
= link_to group_group_member_path(group, group_member), data: { confirm: remove_user_from_group_message(group, group_member) }, method: :delete, remote: true, class: "btn-xs btn btn-remove", title: 'Remove user from group' do | ||
%i.fa.fa-times.fa-inverse | ||
- else | ||
.nothing-here-block This user has no groups. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- page_title "Keys", @user.name, "Users" | ||
= render 'admin/users/head' | ||
= render 'profiles/keys/key_table', admin: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
- page_title "Projects", @user.name, "Users" | ||
= render 'admin/users/head' | ||
|
||
- if @user.groups.any? | ||
.panel.panel-default | ||
.panel-heading Group projects | ||
%ul.well-list | ||
- @user.groups.each do |group| | ||
%li | ||
%strong= group.name | ||
– access to | ||
#{pluralize(group.projects.count, 'project')} | ||
|
||
.row | ||
.col-md-6 | ||
- if @personal_projects.present? | ||
= render 'users/projects', projects: @personal_projects | ||
- else | ||
.nothing-here-block This user has no personal projects. | ||
|
||
|
||
.col-md-6 | ||
.panel.panel-default | ||
.panel-heading Joined projects (#{@joined_projects.count}) | ||
%ul.well-list | ||
- @joined_projects.sort_by(&:name_with_namespace).each do |project| | ||
- member = project.team.find_member(@user.id) | ||
%li.project_member | ||
.list-item-name | ||
= link_to admin_namespace_project_path(project.namespace, project), class: dom_class(project) do | ||
= project.name_with_namespace | ||
|
||
- if member | ||
.pull-right | ||
- if member.owner? | ||
%span.light Owner | ||
- else | ||
%span.light= member.human_access | ||
|
||
- if member.respond_to? :project | ||
= link_to namespace_project_project_member_path(project.namespace, project, member), data: { confirm: remove_from_project_team_message(project, member) }, remote: true, method: :delete, class: "btn-xs btn btn-remove", title: 'Remove user from project' do | ||
%i.fa.fa-times | ||
|
Oops, something went wrong.