Skip to content

Commit

Permalink
Remove set_current_user method
Browse files Browse the repository at this point in the history
  • Loading branch information
onk committed May 3, 2024
1 parent ddaf419 commit d992876
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 65 deletions.
10 changes: 1 addition & 9 deletions app/controllers/concerns/secured.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ module Secured
end

def logged_in_using_omniauth?
if logged_in?
set_current_user
else
redirect_to('/auth/login?origin=' + request.fullpath)
end
redirect_to('/auth/login?origin=' + request.fullpath) unless logged_in?
end

def redirect_to_website
Expand Down Expand Up @@ -70,10 +66,6 @@ def event_name
params[:event]
end

def set_current_user
current_user
end

private

def use_secured_before_action?
Expand Down
10 changes: 1 addition & 9 deletions app/controllers/concerns/secured_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ module SecuredAdmin
end

def logged_in_using_omniauth?
if logged_in?
set_current_user
else
redirect_to('/auth/login?origin=' + request.fullpath)
end
redirect_to('/auth/login?origin=' + request.fullpath) unless logged_in?
end

def logged_in?
Expand All @@ -34,10 +30,6 @@ def is_admin?
raise(Forbidden) unless admin?
end

def set_current_user
current_user
end

def get_or_create_admin_profile
@admin_profile ||= AdminProfile.find_by(email: current_user[:info][:email], conference_id: set_conference.id)

Expand Down
10 changes: 1 addition & 9 deletions app/controllers/concerns/secured_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@ module SecuredApi
end

def logged_in_using_omniauth?
if logged_in?
set_current_user
else
raise(Forbidden)
end
raise(Forbidden) unless logged_in?
end

private

def logged_in?
session[:userinfo].present?
end

def set_current_user
current_user
end
end
6 changes: 1 addition & 5 deletions app/controllers/concerns/secured_beta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module SecuredBeta
extend ActiveSupport::Concern

included do
before_action :set_current_user, :is_beta_user?
before_action :is_beta_user?
end

def beta_user?
Expand All @@ -13,10 +13,6 @@ def is_beta_user?
raise(NotFound) unless beta_user? || admin?
end

def set_current_user
current_user
end

def admin?
current_user[:extra][:raw_info]['https://cloudnativedays.jp/roles'].include?("#{conference.abbr.upcase}-Admin")
end
Expand Down
16 changes: 2 additions & 14 deletions app/controllers/concerns/secured_speaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@ module SecuredSpeaker
end

def logged_in_using_omniauth?
if logged_in?
set_current_user
else
redirect_to("/#{params[:event]}/speaker_dashboard")
end
end

def set_current_user
current_user
redirect_to("/#{params[:event]}/speaker_dashboard") unless logged_in?
end

def logged_in?
Expand All @@ -31,10 +23,6 @@ def speaker?
end

def prepare_create
if logged_in?
set_current_user
else
redirect_to("/#{params[:event]}/speakers/guidance")
end
redirect_to("/#{params[:event]}/speakers/guidance") unless logged_in?
end
end
10 changes: 1 addition & 9 deletions app/controllers/concerns/secured_sponsor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@ module SecuredSponsor
end

def logged_in_using_omniauth?
if logged_in?
set_current_user
else
redirect_to("/#{params[:event]}/sponsor_dashboards/login")
end
end

def set_current_user
current_user
redirect_to("/#{params[:event]}/sponsor_dashboards/login") unless logged_in?
end

def logged_in?
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/event_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class EventController < ApplicationController
include SponsorHelper
include ActionView::Helpers::UrlHelper

before_action :set_current_user, :set_profile, :set_speaker
before_action :set_profile, :set_speaker

def show
@conference = Conference
Expand All @@ -20,10 +20,6 @@ def show
end
end

def set_current_user
current_user
end

def privacy
@conference = Conference.find_by(abbr: params[:event])
end
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
class ProposalsController < ApplicationController
include Secured
before_action :set_current_user, :set_profile, :set_speaker
before_action :set_profile, :set_speaker

helper_method :proposal_status

def logged_in_using_omniauth?
if logged_in?
set_current_user
end
# nop
end

def show
Expand Down
1 change: 0 additions & 1 deletion app/controllers/speaker_dashboard/speakers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class SpeakerDashboard::SpeakersController < ApplicationController
include SecuredSpeaker

skip_before_action :logged_in_using_omniauth?, only: [:new, :guidance]
before_action :set_current_user, only: [:guidance]
before_action :prepare_create, only: [:new]

# GET :event/speaker_dashboard/speakers/guidance
Expand Down

0 comments on commit d992876

Please sign in to comment.