2015-06-18 15:56:15 +00:00
|
|
|
class Admin::IdentitiesController < Admin::ApplicationController
|
2015-06-19 09:46:49 +00:00
|
|
|
before_action :user
|
2015-06-19 10:04:34 +00:00
|
|
|
before_action :identity, except: :index
|
|
|
|
|
|
|
|
def index
|
|
|
|
@identities = @user.identities
|
|
|
|
end
|
2015-06-18 15:56:15 +00:00
|
|
|
|
2015-06-19 09:46:49 +00:00
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if @identity.update_attributes(identity_params)
|
2015-06-19 10:04:34 +00:00
|
|
|
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.'
|
2015-06-19 09:46:49 +00:00
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
2015-06-18 15:56:15 +00:00
|
|
|
|
2015-06-19 09:46:49 +00:00
|
|
|
def destroy
|
2015-06-22 16:01:52 +00:00
|
|
|
if @identity.destroy
|
|
|
|
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully removed.'
|
|
|
|
else
|
|
|
|
redirect_to admin_user_identities_path(@user), alert: 'Failed to remove user identity.'
|
2015-06-18 15:56:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def user
|
|
|
|
@user ||= User.find_by!(username: params[:user_id])
|
|
|
|
end
|
2015-06-19 09:46:49 +00:00
|
|
|
|
|
|
|
def identity
|
|
|
|
@identity ||= user.identities.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def identity_params
|
2015-06-23 08:26:50 +00:00
|
|
|
params.require(:identity).permit(:provider, :extern_uid)
|
2015-06-19 09:46:49 +00:00
|
|
|
end
|
2015-06-18 15:56:15 +00:00
|
|
|
end
|