Sha256: b0408e6497548d884b09b6e1fa45fa98e94ab855c762bed0f97111195ab7cc93

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

module Nyauth
  class ResetPasswordRequestsController < ApplicationController
    include Nyauth::ControllerConcern
    allow_everyone
    self.responder = Nyauth::AppResponder
    respond_to :html, :json
    before_action :set_service
    after_action :send_mail, only: [:create], if: -> { @service.errors.blank? }

    def new
    end

    def create
      @service.save(as: nyauth_client_name)
      respond_with(@service, location: Nyauth.configuration.redirect_path_after_reset_password_request.call(nyauth_client_name) || main_app.root_path)
    end

    private

    def set_service
      @service = Nyauth::ResetPasswordRequest.new(reset_password_request_params)
    end

    def reset_password_request_params
      params.fetch(:reset_password_request, {})
            .permit(:email)
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyauth-0.4.0 app/controllers/nyauth/reset_password_requests_controller.rb