Sha256: 314c4bcdcb11c1141fc368f4fb9a3f7dc78a4f9e5e315d380c2a836ecfa5e064

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

module Zetto::Services::Session

  class Registration

    def initialize(user, cookies, user_agent, remote_ip)
      Zetto::Config::Params.user_class(user.class.to_s)
      unless cookies.class.to_s == "ActionDispatch::Cookies::CookieJar"
        raise ArgumentError.new(I18n.t('exseptions.save_session_cookies'))
      end

      @user = user
      @cookies = cookies
      @user_agent = user_agent
      @remote_ip = remote_ip
    end

    def execute
      if session = Zetto::Storage::Session::Create.new(@user, @user_agent, @remote_ip).execute
        create_cookie(session)
      end
    rescue Exception => e
      Zetto::Services::Info.error_message I18n.t('exseptions.unknown_error', argument: 'Zetto::Services::Session::Registration', current_method: __method__), e
      nil
    end

    private

    def create_cookie(session)
      Zetto::Services::Cookie::SaveSession.new(session, @cookies).execute
    end

  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zetto-2.2.0 lib/zetto/services/session/registration.rb