Browse Source

feat: show invalid page if token invalid

pull/1265/head
natdeanlewissoftwire 3 years ago
parent
commit
dc749ccd2f
  1. 2
      app/controllers/auth/confirmations_controller.rb
  2. 12
      app/views/devise/confirmations/invalid.html.erb
  3. 4
      app/views/devise/confirmations/new.html.erb

2
app/controllers/auth/confirmations_controller.rb

@ -11,6 +11,8 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController
else else
respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) } respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
end end
elsif resource.errors.map(&:type).include?(:invalid)
render "devise/confirmations/invalid"
elsif resource.errors.map(&:type).include?(:already_confirmed) elsif resource.errors.map(&:type).include?(:already_confirmed)
redirect_to user_session_path redirect_to user_session_path
else else

12
app/views/devise/confirmations/invalid.html.erb

@ -0,0 +1,12 @@
<% content_for :title, "Expired link" %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
<%= content_for(:title) %>
</h1>
<p class="govuk-body">It looks like you have requested a newer join link than this one. Check your emails and follow the most recent link instead.</p>
</div>
</div>

4
app/views/devise/confirmations/new.html.erb

@ -1,14 +1,12 @@
<% content_for :title, "Expired link" %> <% content_for :title, "Expired link" %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-full"> <div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l"> <h1 class="govuk-heading-l">
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= f.govuk_error_summary %>
<p class="govuk-body">For security reasons, your join link expired - get another one using the button below (valid for 3 hours).</p> <p class="govuk-body">For security reasons, your join link expired - get another one using the button below (valid for 3 hours).</p>

Loading…
Cancel
Save