Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio-e committed Jul 24, 2024
1 parent cd8f23f commit 906aeca
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ gem "action_policy", "~> 0.7.0"
# Authentication
gem "bcrypt", "~> 3.1.20"

# QR code
gem "rqrcode", "~> 2.0"

# Admin
gem "avo", ">= 3.2.1"
gem "ransack"

# Other
gem "bootsnap", require: false
gem "inline_svg"
gem "puma", ">= 5.0"
gem "ransack"
gem "rqrcode", "~> 2.0"
gem "tzinfo-data", platforms: %i[windows jruby]
gem "validates_timeliness", "~> 7.0.0.beta1"

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module Authentication
extend ActiveSupport::Concern

included do
helper_method :current_user, :user_signed_in?, :authenticate_admin_user!
helper_method :current_user, :user_signed_in?

before_action :authenticate_user!
before_action :authenticate_user, :authenticate_user!
end

class_methods do
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class RegistrationsController < ApplicationController
allow_unauthenticated_access

before_action :redirect_if_signed_in

def new
@user = User.new
end
Expand All @@ -21,4 +23,8 @@ def create
def registration_params
params.require(:user).permit(:email, :password, :password_confirmation)
end

def redirect_if_signed_in
redirect_to root_path if user_signed_in?
end
end
6 changes: 6 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class SessionsController < ApplicationController
allow_unauthenticated_access only: [:new, :create]

before_action :redirect_if_signed_in, only: [:new, :create]

def new
@user = User.new
end
Expand All @@ -26,4 +28,8 @@ def destroy
def session_params
params.require(:user).permit(:email, :password)
end

def redirect_if_signed_in
redirect_to root_path if user_signed_in?
end
end
2 changes: 2 additions & 0 deletions app/models/speaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ class Speaker < ApplicationRecord
has_one :profile, as: :profileable, dependent: :destroy

has_and_belongs_to_many :events

accepts_nested_attributes_for :profile
end
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Rails.application.routes.draw do
root "main#index"

get "up" => "rails/health#show", :as => :rails_health_check

# TODO: authenticate with admin user
mount MissionControl::Jobs::Engine, at: "/jobs"
mount Avo::Engine, at: Avo.configuration.root_path

root "main#index"

resource :registration, only: [:new, :create]
resource :session, only: [:new, :create, :destroy]
resource :password, only: [:edit, :update]
Expand Down

0 comments on commit 906aeca

Please sign in to comment.