Only users with verified emails are allowed to create new jobs

This commit is contained in:
2024-09-17 12:42:59 +02:00
parent b1b24a3b26
commit 848777481d
10 changed files with 37 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ class ApplicationController < ActionController::Base
before_action :set_current_request_details
before_action :authenticate_user!
before_action :verified_user!
verify_authorized
@@ -29,6 +30,15 @@ class ApplicationController < ActionController::Base
end
end
def verified_user!
if user_signed_in?
unless current_user.verified?
flash[:notice] = "Please verify your email!"
redirect_to profile_path
end
end
end
def set_current_request_details
Current.user_agent = request.user_agent
Current.ip_address = request.ip

View File

@@ -1,5 +1,7 @@
class Identity::EmailVerificationsController < ApplicationController
skip_before_action :authenticate_user!, only: :show
skip_before_action :verified_user!
skip_verify_authorized
before_action :set_user, only: :show

View File

@@ -1,4 +1,7 @@
class Identity::EmailsController < ApplicationController
skip_before_action :verified_user!
skip_verify_authorized
before_action :set_user
def edit

View File

@@ -1,5 +1,6 @@
class Identity::PasswordResetsController < ApplicationController
skip_before_action :authenticate_user!
skip_verify_authorized
before_action :set_user, only: %i[ edit update ]

View File

@@ -1,5 +1,6 @@
class JobsController < ApplicationController
skip_before_action :authenticate_user!, only: [ :index, :cancel_button ]
skip_before_action :verified_user!, only: [ :index ]
skip_verify_authorized only: [ :index, :new, :create, :cancel_button ]
# GET /jobs or /jobs.json

View File

@@ -1,5 +1,6 @@
class PasswordsController < ApplicationController
skip_verify_authorized only: [ :edit, :update ]
skip_before_action :verified_user!
before_action :set_user
def edit

View File

@@ -1,5 +1,6 @@
class ProfilesController < ApplicationController
skip_verify_authorized only: [ :show, :edit, :destroy ]
skip_before_action :verified_user!
def show
end

View File

@@ -1,5 +1,6 @@
class SessionsController < ApplicationController
skip_before_action :authenticate_user!, only: %i[ new create ]
skip_before_action :verified_user!
skip_verify_authorized only: [ :index, :new, :create, :destroy ]
before_action :set_session, only: :destroy