adds verification tries to letter code [#332]

This commit is contained in:
rgarcia
2015-09-10 11:43:25 +02:00
parent 02c101cd97
commit 16dd609ad0
5 changed files with 19 additions and 0 deletions

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_attemps_left!
skip_authorization_check
def new
@@ -28,6 +29,7 @@ class Verification::LetterController < ApplicationController
current_user.update(verified_at: Time.now)
redirect_to account_path, notice: t('verification.letter.update.flash.success')
else
@letter.increase_letter_verification_tries
@error = t('verification.letter.update.error')
render :edit
end
@@ -44,4 +46,10 @@ class Verification::LetterController < ApplicationController
redirect_to verified_user_path, alert: t('verification.letter.alert.unconfirmed_code')
end
end
def verify_attemps_left!
if current_user.letter_verification_tries >= 2
redirect_to account_path, alert: t('verification.letter.alert.verify_attemps_left')
end
end
end