- use database data for login
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@189 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
72bf33dbed
commit
68431035d0
2 changed files with 17 additions and 7 deletions
|
@ -14,7 +14,9 @@ class ServiceFacade:
|
|||
gnuviech admin backend.
|
||||
"""
|
||||
def __init__(self):
|
||||
dbconn = psycopg.connect('host=%(dbhost)s user=%(dbuser)s password=%(dbpassword)s dbname=%(dbname)s' % Settings.DBSETTINGS)
|
||||
connstr = 'host=%(dbhost)s user=%(dbuser)s ' + \
|
||||
'password=%(dbpassword)s dbname=%(dbname)s'
|
||||
dbconn = psycopg.connect(connstr % Settings.DBSETTINGS)
|
||||
self.sessionManager = SessionManager(dbconn)
|
||||
self.domainManager = DomainManager(dbconn)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Session manager class for gnuviech-admin tool backend
|
|||
$Id$
|
||||
"""
|
||||
import Settings
|
||||
import os, sha, time, logging
|
||||
import os, sha, time, logging, psycopg
|
||||
from threading import Timer
|
||||
|
||||
SESSIONTIMEOUT=120 # 2 minutes
|
||||
|
@ -45,11 +45,19 @@ class SessionManager:
|
|||
return self._sessions.keys()
|
||||
|
||||
def newSession(self, login, password):
|
||||
cr = self._dbconn.cursor()
|
||||
cr.execute('SELECT * FROM sysuser WHERE name=%(login)s AND md5pass=md5(%(password)s)' %
|
||||
{'login': psycopg.QuotedString(login),
|
||||
'password' : psycopg.QuotedString(password)})
|
||||
self._dbconn.commit()
|
||||
result = cr.fetchall()
|
||||
if cr.rowcount == 1:
|
||||
self._hashobj.update("%s,%s" % (time.time(), login))
|
||||
sessionid = self._hashobj.hexdigest()
|
||||
self._sessions[sessionid] = Session(sessionid, login)
|
||||
self.updateSession(sessionid)
|
||||
return sessionid
|
||||
raise InvalidLoginError
|
||||
|
||||
def updateSession(self, sessionid):
|
||||
self.logger.debug("update session %s" % sessionid)
|
||||
|
|
Loading…
Reference in a new issue