Sha256: 092d4a268c372c0b621369ae4228fc6d2bc523237ed92c8988770716d56b9775

Contents?: true

Size: 692 Bytes

Versions: 10

Compression:

Stored size: 692 Bytes

Contents

class Identity::EmailsController < ApplicationController
  <%- if options.sudoable? -%>
  before_action :require_sudo
  <%- end -%>
  before_action :set_user

  def update
    <%- unless options.sudoable? -%>
    if !@user.authenticate(params[:current_password])
      render json: { error: "The password you entered is incorrect" }, status: :bad_request
    elsif @user.update(user_params)
    <%- else -%>
    if @user.update(user_params)
    <%- end -%>
      render json: @user
    else
      render json: @user.errors, status: :unprocessable_entity
    end
  end

  private
    def set_user
      @user = Current.user
    end

    def user_params
      params.permit(:email)
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
authentication-zero-2.15.0 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.14.0 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.13.0 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.12.6 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.12.5 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.12.4 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.12.3 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.12.2 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.12.1 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
authentication-zero-2.12.0 lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt