summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-19 11:46:49 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-19 15:29:53 +0200
commit270b7ce810775d69887e76162a00e8dc97e5d959 (patch)
tree33855438dcd29daf1a3ee74735f1dbb411a999c6 /app
parent228da2dd28a91b3ab2729787e93e72940975a2bd (diff)
downloadgitlab-ce-270b7ce810775d69887e76162a00e8dc97e5d959.tar.gz
Add ability for admin to edit user identity
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/identities_controller.rb26
-rw-r--r--app/views/admin/identities/_form.html.haml19
-rw-r--r--app/views/admin/identities/_identity.html.haml3
-rw-r--r--app/views/admin/identities/edit.html.haml6
4 files changed, 50 insertions, 4 deletions
diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb
index 6107b1bcb40..795fecd78d6 100644
--- a/app/controllers/admin/identities_controller.rb
+++ b/app/controllers/admin/identities_controller.rb
@@ -1,11 +1,21 @@
class Admin::IdentitiesController < Admin::ApplicationController
- before_action :user, only: [:destroy]
+ before_action :user
+ before_action :identity
- def destroy
- identity = user.identities.find(params[:id])
+ def edit
+ end
+
+ def update
+ if @identity.update_attributes(identity_params)
+ redirect_to admin_user_path(@user), notice: 'User identity was successfully updated.'
+ else
+ render :edit
+ end
+ end
+ def destroy
respond_to do |format|
- if identity.destroy
+ if @identity.destroy
format.html { redirect_to [:admin, user], notice: 'User identity was successfully removed.' }
else
format.html { redirect_to [:admin, user], alert: 'Failed to remove user identity.' }
@@ -18,4 +28,12 @@ class Admin::IdentitiesController < Admin::ApplicationController
def user
@user ||= User.find_by!(username: params[:user_id])
end
+
+ def identity
+ @identity ||= user.identities.find(params[:id])
+ end
+
+ def identity_params
+ params[:identity].permit(:provider, :extern_uid)
+ end
end
diff --git a/app/views/admin/identities/_form.html.haml b/app/views/admin/identities/_form.html.haml
new file mode 100644
index 00000000000..1c34706a124
--- /dev/null
+++ b/app/views/admin/identities/_form.html.haml
@@ -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.text_field :provider, required: true, autocomplete: "off", class: 'form-control', required: true
+ .form-group
+ = f.label :extern_uid, class: 'control-label'
+ .col-sm-10
+ = f.text_field :extern_uid, required: true, autocomplete: "off", class: 'form-control', required: true
+
+ .form-actions
+ = f.submit 'Save changes', class: "btn btn-save"
+
diff --git a/app/views/admin/identities/_identity.html.haml b/app/views/admin/identities/_identity.html.haml
index b94edefaa41..0b7020b887d 100644
--- a/app/views/admin/identities/_identity.html.haml
+++ b/app/views/admin/identities/_identity.html.haml
@@ -4,6 +4,9 @@
%td
= identity.extern_uid
%td
+ = link_to edit_admin_user_identity_path(@user, identity), class: 'btn btn-xs btn-grouped' do
+ %i.fa.fa-edit
+ 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
diff --git a/app/views/admin/identities/edit.html.haml b/app/views/admin/identities/edit.html.haml
new file mode 100644
index 00000000000..d49d79ce5c9
--- /dev/null
+++ b/app/views/admin/identities/edit.html.haml
@@ -0,0 +1,6 @@
+- page_title @user.name, "Users"
+%h3.page-title
+ Edit identity for #{@user.name}
+%hr
+
+= render 'form'