enforce disposable email policy on email verifications / changes

This commit is contained in:
Kyle Drake 2017-05-05 16:02:03 -07:00
parent 2e5cc9b243
commit 0e3b6ee3a0
2 changed files with 4 additions and 1 deletions

View file

@ -173,6 +173,8 @@ post '/site/create_directory' do
end end
get '/site/:username/confirm_email/:token' do get '/site/:username/confirm_email/:token' do
@title = 'Confirm email'
if current_site && current_site.email_confirmed if current_site && current_site.email_confirmed
return erb(:'site_email_confirmed') return erb(:'site_email_confirmed')
end end
@ -201,6 +203,7 @@ end
get '/site/:username/confirm_email' do get '/site/:username/confirm_email' do
require_login require_login
@title = 'Confirm your Email Address'
@fromsettings = session[:fromsettings] @fromsettings = session[:fromsettings]
redirect '/' if current_site.username != params[:username] || !current_site.parent? || current_site.email_confirmed redirect '/' if current_site.username != params[:username] || !current_site.parent? || current_site.email_confirmed
erb :'site/confirm_email' erb :'site/confirm_email'

View file

@ -912,7 +912,7 @@ class Site < Sequel::Model
errors.add :email, 'Cannot use this email address.' errors.add :email, 'Cannot use this email address.'
end end
if parent? && new? && self.class.disposable_email?(values[:email]) if parent? && (values[:created_at].nil? || values[:created_at] > 1.week.ago) && self.class.disposable_email?(values[:email])
errors.add :email, 'Cannot use a disposable email address.' errors.add :email, 'Cannot use a disposable email address.'
end end