Added better handling of record not found and invalid login tokens

This commit is contained in:
Godwin
2016-08-06 20:48:47 -07:00
parent 973ca46c08
commit 94433dde28
6 changed files with 20 additions and 8 deletions
+6 -1
View File
@@ -357,7 +357,12 @@ class ApplicationController < LinguaFrancaApplicationController
end
def confirm(uid = nil)
@confirmation = EmailConfirmation.find_by_token!(params[:token])
@confirmation = EmailConfirmation.find_by_token(params[:token])
unless @confirmation.present?
@token_not_found = true
return do_404
end
confirm_user = nil
if uid.is_a?(User)
@@ -2064,11 +2064,16 @@ class ConferencesController < ApplicationController
return registration_steps(registration.conference).last
end
rescue_from ActiveRecord::RecordNotFound do |exception|
do_404
end
rescue_from ActiveRecord::PremissionDenied do |exception|
if logged_in?
redirect_to :register
else
@register_template = :confirm_email
@page_title = "articles.conference_registration.headings.#{@this_conference.registration_status == :open ? '': 'Pre_'}Registration_Details"
render :register
end
end
+6 -2
View File
@@ -1,5 +1,9 @@
= render :partial => 'application/header', :locals => {:image_file => nil}
= row do
= columns(medium: 12) do
%p= _'error.404.description', :p
= render 'contact', cancel_btn: false, contact_reason: :website
- if @token_not_found.present?
%p= _'error.404.token_not_found', :p
= render 'login', dest: settings_path
- else
%p= _'error.404.description', :p
= render 'contact', cancel_btn: false, contact_reason: :website
@@ -13,7 +13,6 @@
- @conferences.each do | conference |
= link_to (_!conference.title), administration_step_path(conference.slug, :edit), class: :button
= form_tag update_settings_path do
= textfield :name, current_user.name, required: true, heading: 'articles.conference_registration.headings.name', big: true
= checkboxes :languages, User.AVAILABLE_LANGUAGES, current_user.languages || [I18n.locale], 'languages', heading: 'articles.conference_registration.headings.languages'
@@ -23,7 +22,4 @@
= button_tag :save, value: :save
- else
%h2=_'forms.actions.generic.login'
= form_tag do_confirm_path, class: 'flex-form' do
= emailfield :email, nil, big: true
= button_tag :continue, :value => :confirm_email
= link_to (_'forms.actions.generic.facebook_sign_in','Facebook Sign In'), auth_at_provider_path(provider: :facebook), class: [:button, :facebook]
= render 'login'