Add logic to user verification

changed functions on verification.rb, the first thing they do is
return true whene skip_user_verification is active.
changed show_welcome_screen? on user.rb, now its shows the welcome
page even with te option active.
changed welcome.html.erb, now if the user see this view and the
option is activated, all 4 checks are green, not only 2.
This commit is contained in:
Raúl Fuentes
2018-04-10 15:09:01 +02:00
parent 63213a0e4d
commit 376ce443ef
3 changed files with 37 additions and 4 deletions

View File

@@ -10,31 +10,42 @@ module Verification
scope :incomplete_verification, -> { where("(users.residence_verified_at IS NULL AND users.failed_census_calls_count > ?) OR (users.residence_verified_at IS NOT NULL AND (users.unconfirmed_phone IS NULL OR users.confirmed_phone IS NULL))", 0) }
end
def skip_verification?
Setting["feature.user.skip_verification"].present?
end
def verification_email_sent?
return true if skip_verification?
email_verification_token.present?
end
def verification_sms_sent?
return true if skip_verification?
unconfirmed_phone.present? && sms_confirmation_code.present?
end
def verification_letter_sent?
return true if skip_verification?
letter_requested_at.present? && letter_verification_code.present?
end
def residence_verified?
return true if skip_verification?
residence_verified_at.present?
end
def sms_verified?
return true if skip_verification?
confirmed_phone.present?
end
def level_two_verified?
return true if skip_verification?
level_two_verified_at.present? || (residence_verified? && sms_verified?)
end
def level_three_verified?
return true if skip_verification?
verified_at.present?
end

View File

@@ -247,7 +247,8 @@ class User < ActiveRecord::Base
end
def show_welcome_screen?
sign_in_count == 1 && unverified? && !organization && !administrator?
verification = Setting["feature.user.skip_verification"].present? ? true : unverified?
sign_in_count == 1 && verification && !organization && !administrator?
end
def password_required?

View File

@@ -7,8 +7,22 @@
<ul>
<li><span class="icon-check"></span>&nbsp;<%= t("welcome.welcome.user_permission_debates") %></li>
<li><span class="icon-check"></span>&nbsp;<%= t("welcome.welcome.user_permission_proposal") %></li>
<li><span class="icon-x"></span>&nbsp;<%= t("welcome.welcome.user_permission_support_proposal") %></li>
<li><span class="icon-x"></span>&nbsp;<%= t("welcome.welcome.user_permission_votes") %></li>
<li>
<% if current_user.level_two_or_three_verified? %>
<span class="icon-check"></span>
<% else %>
<span class="icon-x"></span>
<% end %>
<%= t("welcome.welcome.user_permission_support_proposal") %>
</li>
<li>
<% if current_user.level_three_verified? %>
<span class="icon-check"></span>
<% else %>
<span class="icon-x"></span>
<% end %>
<%= t("welcome.welcome.user_permission_votes") %>
</li>
</ul>
<p>
@@ -19,7 +33,14 @@
<%= t("welcome.welcome.user_permission_verify") %>
</p>
<%= link_to(t("welcome.welcome.user_permission_verify_my_account"), verification_path, class: "button success radius expand") %>
<% if current_user.level_three_verified? %>
<p class="already-verified">
<span class="icon-check"></span>
<%= t("account.show.verified_account") %>
</p>
<% else %>
<%= link_to(t("welcome.welcome.user_permission_verify_my_account"), verification_path, class: "button success radius expand") %>
<% end %>
<p class="text-center">
<%= link_to t("welcome.welcome.go_to_index"), proposals_path %>