aboutsummaryrefslogtreecommitdiffstats
path: root/packages/torouter-web/src/tui/utils/session.py
blob: a554dadc74b654b986600d641ea44fcf9074e202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import web
import config

# The main session class
  
def add_session_to_app(app):

  if web.config.get("_session") is None:
    store = web.session.DiskStore('sessions')
    session = web.session.Session(app, store, initializer={'login': 0, 'privilege': 0})
    web.config._session = session
  else:
    session = web.config._session

def is_logged():
  return web.config._session.login

def check_login(data):
  if (data.user == config.authinfo[0]) and (data.password == config.authinfo[1]):
    web.config._session.login = 1
    return 0
  return 1

def logout():
  web.config._session.kill()