2015-06-18 11:56:15 -04:00
|
|
|
class Admin::IdentitiesController < Admin::ApplicationController
|
2015-06-19 05:46:49 -04:00
|
|
|
before_action :user
|
2015-12-11 15:33:15 -05:00
|
|
|
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-06-19 06:04:34 -04:00
|
|
|
|
|
|
|
def index
|
|
|
|
@identities = @user.identities
|
|
|
|
end
|
2015-06-18 11:56:15 -04:00
|
|
|
|
2015-06-19 05:46:49 -04:00
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2018-07-02 06:43:06 -04:00
|
|
|
if @identity.update(identity_params)
|
2016-01-07 11:01:01 -05:00
|
|
|
RepairLdapBlockedUserService.new(@user).execute
|
2015-06-19 06:04:34 -04:00
|
|
|
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.'
|
2015-06-19 05:46:49 -04:00
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
2015-06-18 11:56:15 -04:00
|
|
|
|
2015-06-19 05:46:49 -04:00
|
|
|
def destroy
|
2015-06-22 12:01:52 -04:00
|
|
|
if @identity.destroy
|
2016-01-07 11:01:01 -05:00
|
|
|
RepairLdapBlockedUserService.new(@user).execute
|
2017-06-06 18:45:16 -04:00
|
|
|
redirect_to admin_user_identities_path(@user), status: 302, notice: 'User identity was successfully removed.'
|
2015-06-22 12:01:52 -04:00
|
|
|
else
|
2017-06-06 18:45:16 -04:00
|
|
|
redirect_to admin_user_identities_path(@user), status: 302, alert: 'Failed to remove user identity.'
|
2015-06-18 11:56:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def user
|
|
|
|
@user ||= User.find_by!(username: params[:user_id])
|
|
|
|
end
|
2015-06-19 05:46:49 -04:00
|
|
|
|
|
|
|
def identity
|
|
|
|
@identity ||= user.identities.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def identity_params
|
2015-06-23 04:26:50 -04:00
|
|
|
params.require(:identity).permit(:provider, :extern_uid)
|
2015-06-19 05:46:49 -04:00
|
|
|
end
|
2015-06-18 11:56:15 -04:00
|
|
|
end
|