debian-mirror-gitlab/app/controllers/admin/identities_controller.rb

59 lines
1.4 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
class Admin::IdentitiesController < Admin::ApplicationController
before_action :user
2015-12-23 02:04:40 +05:30
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
2015-09-11 14:41:01 +05:30
def index
@identities = @user.identities
end
def edit
end
def update
if @identity.update_attributes(identity_params)
RepairLdapBlockedUserService.new(@user).execute
2015-09-11 14:41:01 +05:30
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.'
else
render :edit
end
end
def destroy
if @identity.destroy
RepairLdapBlockedUserService.new(@user).execute
2017-09-10 17:25:29 +05:30
redirect_to admin_user_identities_path(@user), status: 302, notice: 'User identity was successfully removed.'
2015-09-11 14:41:01 +05:30
else
2017-09-10 17:25:29 +05:30
redirect_to admin_user_identities_path(@user), status: 302, alert: 'Failed to remove user identity.'
2015-09-11 14:41:01 +05:30
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