Class: SessionManager::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/session_manager.rb,
lib/session_manager/handler.rb

Constant Summary collapse

USERS_SESSIONS =
'users_sessions'
APPS_SESSIONS =
'applications_sessions'

Class Method Summary collapse

Class Method Details

.create_session(attribute, option) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/session_manager/handler.rb', line 12

def self.create_session(attribute,option) 
  if validate_option(option) && valid_token?(attribute,option) 
    param = parse_json(attribute)
    collection = collection(option)
    token = generate_token
    session = session_generator(option,param,token)
    result = get_redis.sadd(collection,session.to_json)
    result ? return_response(200,token) : return_response(400,"Not created")
  else
    return_response(400,"Not created")
  end
end

.delete_session(object, option) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/session_manager/handler.rb', line 36

def self.delete_session(object,option)
   if validate_option(option) && validate_json(object,option)
    collection = collection(option)
    result     = get_redis.srem(collection,object)
    result ? return_response(200,"Succesfully deleted") : return_response(400,"Not deleted")
   else
       return_response(400,"Not deleted")
   end
end

.verify_session(object, option) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/session_manager/handler.rb', line 25

def self.verify_session(object,option)
  if validate_option(option) && validate_json(object,option)   
   collection = collection(option)
   result     = get_redis.sismember(collection,object)
   result ? return_response(200,"Ok") : return_response(400,"Not ok") 
  else
      return_response(400,"Ok")
  end
end