Skip to content

Commit

Permalink
Merge pull request #158 from TelosLabs/handle-invalid-auth-token
Browse files Browse the repository at this point in the history
Fix | Handle invalid auth token
  • Loading branch information
andresag4 committed Sep 2, 2024
2 parents f1b2f84 + 46023cb commit e3b2f30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
10 changes: 9 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ class ApplicationController < ActionController::Base

helper_method :current_profile, :current_conference, :vapid_public_key

rescue_from ActionController::InvalidAuthenticityToken,
with: :after_invalid_authenticity_token

private

def current_profile = current_user&.profile

# TODO: Must change after implementing multi-conference support
def current_conference = Conference.last

def vapid_public_key
Base64.urlsafe_decode64(ENV["VAPID_PUBLIC_KEY"]).bytes.to_json
end

def after_invalid_authenticity_token
path_to_redirect = request.referer
path_to_redirect ||= user_signed_in? ? sessions_path : new_user_session_path
redirect_to path_to_redirect, alert: t("authorization.invalid_auth_token")
end
end
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ en:
submit: "Apply"
authorization:
unauthorized: "You are not authorized to access this page."
invalid_auth_token: "Your request has expired. Please try again."
session_mailer:
reminder:
subject: "This session is starting soon"
Expand All @@ -66,4 +67,3 @@ en:
one: "1month"
other: "%{count}months"
x_months: "%{count}months"

20 changes: 0 additions & 20 deletions lib/tasks/db.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace :db do
desc "Loading Rails World 2024 conference data."

task :rails_world_2024_seed, [:start_date] => :environment do |t, args|
start_date = args[:start_date].present? ? Date.parse(args[:start_date]) : Date.new(2024, 9, 26)
month = start_date.month
Expand All @@ -25,43 +24,24 @@ namespace :db do

# Create Tags
community = Tag.find_or_create_by!(name: "Community")

security = Tag.find_or_create_by!(name: "Security")

rails_8 = Tag.find_or_create_by!(name: "Rails 8")

productivity = Tag.find_or_create_by!(name: "Productivity")

tools = Tag.find_or_create_by!(name: "Tools")

developer_experience = Tag.find_or_create_by!(name: "Developer Experience")

deployment = Tag.find_or_create_by!(name: "Deployment")

performance = Tag.find_or_create_by!(name: "Performance")

storage_solutions = Tag.find_or_create_by!(name: "Storage Solutions")

refactoring = Tag.find_or_create_by!(name: "Refactoring")

database = Tag.find_or_create_by!(name: "Database")

hotwire = Tag.find_or_create_by!(name: "Hotwire")

ai = Tag.find_or_create_by!(name: "AI")

integrations = Tag.find_or_create_by!(name: "Integrations")

testing = Tag.find_or_create_by!(name: "Testing")

best_practices = Tag.find_or_create_by!(name: "Best Practices")

pwa = Tag.find_or_create_by!(name: "PWA")

insights = Tag.find_or_create_by!(name: "Insights")

background_jobs = Tag.find_or_create_by!(name: "Background Jobs")

rails_internals = Tag.find_or_create_by!(name: "Rails Internals")

# Create Speakers
Expand Down

0 comments on commit e3b2f30

Please sign in to comment.