Sha256: 6e4c84ef31b870a4a863c8a7a0c0d54f5e823d9704bdfcb38918dd083e99da27

Contents?: true

Size: 883 Bytes

Versions: 12

Compression:

Stored size: 883 Bytes

Contents

class Identity::EmailVerificationsController < ApplicationController
  skip_before_action :authenticate, only: :edit

  before_action :set_user, only: :edit

  def edit
    @user.update! verified: true
  end

  def create
    UserMailer.with(user: Current.user).email_verification.deliver_later
  end

  private
    def set_user
    <%- if code_verifiable? -%>
      verified_user = User.find_by(email: params[:email])

      if verified_user && verified_user.verification_code.value == params[:token]
        @user = verified_user
      else
        render json: { error: "That email verification code is invalid" }, status: :bad_request
      end
    <%- else -%>
      @token = EmailVerificationToken.find_signed!(params[:sid]); @user = @token.user
    rescue
      render json: { error: "That email verification link is invalid" }, status: :bad_request
    <%- end -%>
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
authentication-zero-2.15.9 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.8 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.7 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.6 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.5 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.4 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.3 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.2 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.1 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.15.0 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.14.0 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
authentication-zero-2.13.0 lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt