Sha256: 50b28e77e1603efdacf0cb4740984ebd25356a12b91ee0e00403d7d9ae1d4a55

Contents?: true

Size: 982 Bytes

Versions: 1

Compression:

Stored size: 982 Bytes

Contents

module Nyauth
  class ConfirmationRequestsController < 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_create_request_confirmation.call(nyauth_client_name) || main_app.root_path)
    end

    private

    def set_service
      @service = Nyauth::ConfirmationRequest.new(confirmation_request_params)
    end

    def confirmation_request_params
      params.fetch(:confirmation_request, {})
            .permit(:email)
    end

    def send_mail
      Nyauth::RequestMailer.request_confirmation(@service.client)
                           .__send__(Nyauth.configuration.mail_delivery_method)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyauth-0.5.0 app/controllers/nyauth/confirmation_requests_controller.rb