diff --git a/app/controllers/verification/verified_user_controller.rb b/app/controllers/verification/verified_user_controller.rb new file mode 100644 index 000000000..bf2bc65fb --- /dev/null +++ b/app/controllers/verification/verified_user_controller.rb @@ -0,0 +1,9 @@ +class Verification::VerifiedUserController < ApplicationController + before_action :authenticate_user! + skip_authorization_check + + def show + @verified_users = VerifiedUser.by_user(current_user) + redirect_to new_sms_path if @verified_users.blank? + end +end \ No newline at end of file diff --git a/app/models/verified_user.rb b/app/models/verified_user.rb new file mode 100644 index 000000000..ca32eea5c --- /dev/null +++ b/app/models/verified_user.rb @@ -0,0 +1,12 @@ +# make sure document_type is being stored and queried in the correct format (Is it DNI? a number, a string?) +class VerifiedUser < ActiveRecord::Base + scope :by_user, -> (user) { where(document_number: user.document_number, + document_type: user.document_type) } + + scope :by_email, -> (email) { where(email: email) } + scope :by_phone, -> (phone) { where(phone: phone) } + + def self.phone?(user) + by_user(user).by_phone(user.unconfirmed_phone).first.present? + end +end diff --git a/app/views/verification/verified_user/show.html.erb b/app/views/verification/verified_user/show.html.erb new file mode 100644 index 000000000..bb61e8546 --- /dev/null +++ b/app/views/verification/verified_user/show.html.erb @@ -0,0 +1,49 @@ +