Sha256: 1159648f118f6174b5a3678dc10c8832cb88027454e327c0a2d9a2019c44be56

Contents?: true

Size: 887 Bytes

Versions: 2

Compression:

Stored size: 887 Bytes

Contents

module Nyauth
  class ResetPasswordRequestsController < ApplicationController
    include Nyauth::ApplicationConcern
    include Nyauth::ClientConcern
    allow_everyone
    self.responder = Nyauth::AppResponder
    respond_to :html, :json
    before_action :set_client, only: [:create]
    after_action :send_mail, only: [:create], if: -> { @client.reset_password_key.present? }

    def new
    end

    def create
      @client.request_reset_password
      respond_with(@client, location: Nyauth.configuration.redirect_path_after_reset_password_request.call(client_name) || main_app.root_path)
    end

    private

    def set_client
      @client = client_class.find_by!(email: params[client_name][:email])
    rescue ActiveRecord::RecordNotFound
      render :new
    end

    def send_mail
      Nyauth::RequestMailer.request_reset_password(@client).deliver_now
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nyauth-0.2.8 app/controllers/nyauth/reset_password_requests_controller.rb
nyauth-0.2.7 app/controllers/nyauth/reset_password_requests_controller.rb