Sha256: 0d0136c30374226b07e689c58171143eb6e183ba1706c2a778bca7f08b02952a

Contents?: true

Size: 855 Bytes

Versions: 8

Compression:

Stored size: 855 Bytes

Contents

class Identity::EmailsController < ApplicationController
  before_action :set_user

  def edit
  end

  def update
   if !@user.authenticate(params[:current_password])
      redirect_to edit_identity_email_path, alert: "The password you entered is incorrect"
    elsif @user.update(user_params)
      redirect_to_root
    else
      render :edit, status: :unprocessable_entity
    end
  end

  private
    def set_user
      @user = Current.user
    end

    def user_params
      params.permit(:email)
    end

    def redirect_to_root
      if @user.email_previously_changed?
        resend_email_verification
        redirect_to root_path, notice: "Your email has been changed"
      else
        redirect_to root_path
      end
    end

    def resend_email_verification
      UserMailer.with(user: @user).email_verification.deliver_later
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
authentication-zero-2.16.13 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-2.16.12 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-2.16.11 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-2.16.10 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-2.16.9 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-2.16.8 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-2.16.7 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-2.16.6 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt