diff options
author | Brett Walker <brett@digitalmoksha.com> | 2017-09-12 18:39:38 +0300 |
---|---|---|
committer | Brett Walker <brett@digitalmoksha.com> | 2017-09-23 16:24:53 +0300 |
commit | 09726bdf446b4673d4f92bc9132a6e34f3a67160 (patch) | |
tree | 6ffc8b4f91e91efe3183913631791408008b7a7c /app | |
parent | 30e3a49e23f8ce0c2a07b13addc45951d7fc6719 (diff) |
small cleanup changes based on feedback
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 14 | ||||
-rw-r--r-- | app/views/devise/mailer/confirmation_instructions.html.haml | 5 | ||||
-rw-r--r-- | app/views/devise/mailer/confirmation_instructions.text.erb | 6 |
3 files changed, 11 insertions, 14 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index cdc7c8ad84a..5e1355662b6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -810,6 +810,10 @@ class User < ActiveRecord::Base avatar_path(args) || GravatarService.new.execute(email, size, scale, username: username) end + def primary_email_verified? + confirmed? && !temp_oauth_email? + end + def all_emails all_emails = [] all_emails << email unless temp_oauth_email? @@ -817,15 +821,15 @@ class User < ActiveRecord::Base all_emails end - def all_verified_emails + def verified_emails verified_emails = [] - verified_emails << email if confirmed? && !temp_oauth_email? - verified_emails.concat(emails.select {|e| e.confirmed?}.map(&:email)) + verified_emails << email if primary_email_verified? + verified_emails.concat(emails.where.not(confirmed_at: nil).pluck(:email)) verified_emails end - def verified_email?(email) - all_verified_emails.include?(email) + def verified_email?(check_email) + (email == check_email && primary_email_verified?) || verified_emails.include?(check_email) end def hook_attrs diff --git a/app/views/devise/mailer/confirmation_instructions.html.haml b/app/views/devise/mailer/confirmation_instructions.html.haml index a0fb687e152..d2685140913 100644 --- a/app/views/devise/mailer/confirmation_instructions.html.haml +++ b/app/views/devise/mailer/confirmation_instructions.html.haml @@ -1,4 +1 @@ -- if @resource.is_a?(User) - = render partial: 'confirmation_instructions_account' -- else - = render partial: 'confirmation_instructions_secondary' += render partial: "confirmation_instructions_#{@resource.is_a?(User) ? 'account' : 'secondary'}"
\ No newline at end of file diff --git a/app/views/devise/mailer/confirmation_instructions.text.erb b/app/views/devise/mailer/confirmation_instructions.text.erb index 057bb0b23f9..05fddddf415 100644 --- a/app/views/devise/mailer/confirmation_instructions.text.erb +++ b/app/views/devise/mailer/confirmation_instructions.text.erb @@ -1,5 +1 @@ -<% if @resource.is_a?(User) %> -<%= render partial: 'confirmation_instructions_account' %> -<% else %> -<%= render partial: 'confirmation_instructions_secondary' %> -<% end %> +<%= render partial: "confirmation_instructions_#{@resource.is_a?(User) ? 'account' : 'secondary'}" %>
\ No newline at end of file |