aboutsummaryrefslogtreecommitdiffstats
path: root/packages/torouter-web/tui/utils/session.py
blob: 61c04cd4440b9dd32046cf18ec97660dbee19278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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