Module: Virtuatable::Helpers::Sessions

Included in:
Controllers::Base
Defined in:
lib/virtuatable/helpers/sessions.rb

Overview

This helper gives access to methods about user’s session on the API.

Author:

Instance Method Summary collapse

Instance Method Details

#sessionArkaan::Authentication::Session

Returns the session of the user requesting the API.

Returns:

  • (Arkaan::Authentication::Session)

    the session of the requester.



10
11
12
# File 'lib/virtuatable/helpers/sessions.rb', line 10

def session
  Arkaan::Authentication::Session.where(token: params['session_id']).first
end

#session!Object

Checks the session of the user requesting the API and returns an error if it either not exists with the given token, or the token is not given.

Raises:



21
22
23
24
25
26
# File 'lib/virtuatable/helpers/sessions.rb', line 21

def session!
  check_presence 'session_id'
  api_not_found 'session_id.unknown' if session.nil?

  session
end