Allow user to remove openid

This commit is contained in:
Dimitris 2017-06-10 19:36:12 +03:00 committed by Stella Rouzi
parent 703dce4f5c
commit be72b9d02e
4 changed files with 19 additions and 2 deletions

View file

@ -0,0 +1,9 @@
class OpenidsController < ApplicationController
load_and_authorize_resource :user
load_and_authorize_resource through: :user
def destroy
@openid.destroy
redirect_to :back
end
end

View file

@ -100,6 +100,8 @@ class Ability
# can manage the commercials of their own events
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
can [:destroy], Openid
end
# Abilities for signed in users with roles

View file

@ -15,7 +15,11 @@
%h4
Currently the following openIDs are associated with your account
- @openids.each do |openid|
%li= "#{openid.provider}:#{openid.email}"
%li{ style: "list-style: none; margin-left: 20px;" }
= link_to user_openid_path(openid, user_id: current_user.id), method: :delete,
data: { confirm: "Remove association with #{openid.provider} account?" } do
%span.fa.fa-times{ style: "color: red;" }
%span #{openid.provider}:#{openid.email}
%br
%h4
To add an openID with a different email address to your account, sign in with your

View file

@ -15,7 +15,9 @@ Osem::Application.routes.draw do
mount LetterOpenerWeb::Engine, at: "/letter_opener"
end
resources :users, except: [:new, :index, :create, :destroy]
resources :users, except: [:new, :index, :create, :destroy] do
resources :openids, only: :destroy
end
namespace :admin do
resources :organizations