adds before action for verified users

This commit is contained in:
Juanjo Bazán
2015-09-11 16:44:52 +02:00
parent 1296668606
commit f517d7f410
7 changed files with 23 additions and 0 deletions

View File

@@ -96,4 +96,8 @@ class ApplicationController < ActionController::Base
redirect_to new_residence_path, alert: t('verification.residence.alert.unconfirmed_residency')
end
end
def verify_verified!
redirect_to(account_path, notice: t('verification.redirect_notices.already_verified')) if current_user.level_three_verified?
end
end

View File

@@ -1,5 +1,6 @@
class Verification::EmailController < ApplicationController
before_action :authenticate_user!
before_action :verify_verified!
before_action :set_verified_user, only: :create
skip_authorization_check

View File

@@ -2,6 +2,7 @@ class Verification::LetterController < ApplicationController
before_action :authenticate_user!
before_action :verify_resident!
before_action :verify_phone!
before_action :verify_verified!
before_action :verify_lock
skip_authorization_check

View File

@@ -1,5 +1,6 @@
class Verification::ResidenceController < ApplicationController
before_action :authenticate_user!
before_action :verify_verified!
before_action :verify_lock, only: [:new, :create]
skip_authorization_check

View File

@@ -1,6 +1,7 @@
class Verification::SmsController < ApplicationController
before_action :authenticate_user!
before_action :verify_resident!
before_action :verify_verified!
before_action :verify_lock, only: [:new, :create]
before_action :set_phone, only: :create

View File

@@ -1,5 +1,6 @@
class Verification::VerifiedUserController < ApplicationController
before_action :authenticate_user!
before_action :verify_verified!
skip_authorization_check
def show

View File

@@ -74,4 +74,18 @@ feature 'Verification path' do
expect(current_path).to eq new_residence_path
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