Sha256: abd6310dd7d7ab61370a40facf819c44645ae7304ec1e03ad9f1de3dd2fc9eab

Contents?: true

Size: 767 Bytes

Versions: 8

Compression:

Stored size: 767 Bytes

Contents

class Identity::EmailsController < ApplicationController
  before_action :set_user

  def edit
  end

  def update
    if @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, :password_challenge).with_defaults(password_challenge: "")
    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-4.0.3 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-4.0.2 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-4.0.1 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-4.0.0 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-3.0.2 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-3.0.1 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-3.0.0 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
authentication-zero-3.0.0.alpha1 lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt