adds before action for verified users
This commit is contained in:
@@ -96,4 +96,8 @@ class ApplicationController < ActionController::Base
|
|||||||
redirect_to new_residence_path, alert: t('verification.residence.alert.unconfirmed_residency')
|
redirect_to new_residence_path, alert: t('verification.residence.alert.unconfirmed_residency')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def verify_verified!
|
||||||
|
redirect_to(account_path, notice: t('verification.redirect_notices.already_verified')) if current_user.level_three_verified?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Verification::EmailController < ApplicationController
|
class Verification::EmailController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
before_action :verify_verified!
|
||||||
before_action :set_verified_user, only: :create
|
before_action :set_verified_user, only: :create
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class Verification::LetterController < ApplicationController
|
|||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :verify_resident!
|
before_action :verify_resident!
|
||||||
before_action :verify_phone!
|
before_action :verify_phone!
|
||||||
|
before_action :verify_verified!
|
||||||
before_action :verify_lock
|
before_action :verify_lock
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Verification::ResidenceController < ApplicationController
|
class Verification::ResidenceController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
before_action :verify_verified!
|
||||||
before_action :verify_lock, only: [:new, :create]
|
before_action :verify_lock, only: [:new, :create]
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Verification::SmsController < ApplicationController
|
class Verification::SmsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :verify_resident!
|
before_action :verify_resident!
|
||||||
|
before_action :verify_verified!
|
||||||
before_action :verify_lock, only: [:new, :create]
|
before_action :verify_lock, only: [:new, :create]
|
||||||
before_action :set_phone, only: :create
|
before_action :set_phone, only: :create
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Verification::VerifiedUserController < ApplicationController
|
class Verification::VerifiedUserController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
before_action :verify_verified!
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
@@ -74,4 +74,18 @@ feature 'Verification path' do
|
|||||||
|
|
||||||
expect(current_path).to eq new_residence_path
|
expect(current_path).to eq new_residence_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "A verified user can not access verification pages" do
|
||||||
|
user = create(:user, verified_at: Time.now)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
|
||||||
|
verification_paths = [new_residence_path, verified_user_path, edit_sms_path, new_letter_path, edit_letter_path]
|
||||||
|
verification_paths.each do |step_path|
|
||||||
|
visit step_path
|
||||||
|
|
||||||
|
expect(current_path).to eq account_path
|
||||||
|
expect(page).to have_content 'You are a verified user!'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user