Sha256: 76fca68da4bbf2b4b2d13d554f42d894a6069b1b0970f2f838dc6677178451fe

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

class EmailVerificationsController < ApplicationController
  before_action :set_<%= singular_table_name %>, only: %i[ edit update ]

  def edit
    @<%= singular_table_name %>.update! verified: true
    redirect_to root_path, notice: "Thank you for verifying your email address"
  end

  def create
    IdentityMailer.with(<%= singular_table_name %>: Current.<%= singular_table_name %>).email_verify_confirmation.deliver_later
    redirect_to root_path, notice: "We sent a verification email to your email address"
  end

  private
    def set_<%= singular_table_name %>
      @<%= singular_table_name %> = <%= class_name %>.where(email: params[:email]).find_signed!(params[:token], purpose: params[:email])
    rescue ActiveSupport::MessageVerifier::InvalidSignature, ActiveRecord::RecordNotFound
      redirect_to edit_email_path, alert: "That email verification link is invalid"
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authentication-zero-2.2.6 lib/generators/authentication/templates/controllers/html/email_verifications_controller.rb.tt