From 270b7ce810775d69887e76162a00e8dc97e5d959 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 19 Jun 2015 11:46:49 +0200 Subject: Add ability for admin to edit user identity Signed-off-by: Dmitriy Zaporozhets --- app/controllers/admin/identities_controller.rb | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'app/controllers/admin') 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 -- cgit v1.2.1