summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2015-12-21 17:58:20 +0000
committerRobert Speicher <robert@gitlab.com>2015-12-21 17:58:20 +0000
commitf4c05ee45fda4ee2c76f4cbecb0dc6a1f80d2e83 (patch)
tree40073382c03ac6623133a6b8cb374014b838e048
parent12b6bf5c57588b011fd711023bf48eeabea02793 (diff)
parent577448ab6ab35abbf0263bf8677dfde6d9770c3f (diff)
downloadgitlab-ce-f4c05ee45fda4ee2c76f4cbecb0dc6a1f80d2e83.tar.gz
Merge branch 'admin_add_identity' into 'master'
Allow admin to create new user identities Fixes #2442 See merge request !2077
-rw-r--r--app/controllers/admin/identities_controller.rb17
-rw-r--r--app/views/admin/identities/index.html.haml1
-rw-r--r--app/views/admin/identities/new.html.haml4
-rw-r--r--config/routes.rb2
4 files changed, 22 insertions, 2 deletions
diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb
index d28614731f9..e383fe38ea6 100644
--- a/app/controllers/admin/identities_controller.rb
+++ b/app/controllers/admin/identities_controller.rb
@@ -1,6 +1,21 @@
class Admin::IdentitiesController < Admin::ApplicationController
before_action :user
- before_action :identity, except: :index
+ before_action :identity, except: [:index, :new, :create]
+
+ def new
+ @identity = Identity.new
+ end
+
+ def create
+ @identity = Identity.new(identity_params)
+ @identity.user_id = user.id
+
+ if @identity.save
+ redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully created.'
+ else
+ render :new
+ end
+ end
def index
@identities = @user.identities
diff --git a/app/views/admin/identities/index.html.haml b/app/views/admin/identities/index.html.haml
index 8358a14445b..741d111fb7d 100644
--- a/app/views/admin/identities/index.html.haml
+++ b/app/views/admin/identities/index.html.haml
@@ -1,6 +1,7 @@
- page_title "Identities", @user.name, "Users"
= render 'admin/users/head'
+= link_to 'New Identity', new_admin_user_identity_path, class: 'pull-right btn btn-new'
- if @identities.present?
.table-holder
%table.table
diff --git a/app/views/admin/identities/new.html.haml b/app/views/admin/identities/new.html.haml
new file mode 100644
index 00000000000..e30bf0ef0ee
--- /dev/null
+++ b/app/views/admin/identities/new.html.haml
@@ -0,0 +1,4 @@
+- page_title "New Identity"
+%h3.page-title New identity
+%hr
+= render 'form'
diff --git a/config/routes.rb b/config/routes.rb
index 57be57e3251..b9242327de1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -188,7 +188,7 @@ Rails.application.routes.draw do
namespace :admin do
resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
resources :keys, only: [:show, :destroy]
- resources :identities, only: [:index, :edit, :update, :destroy]
+ resources :identities, except: [:show]
delete 'stop_impersonation' => 'impersonation#destroy', on: :collection