correction du bug de login (j'espre)

darcs-hash:20061117140933-f46e9-af7e3b0bf4126861a3e9f9c1eb09227c3c6535c7.gz
This commit is contained in:
gdetrez 2006-11-17 15:09:33 +01:00
parent b488b68dcf
commit 4f3b212b2d
6 changed files with 80 additions and 86 deletions

View file

@ -49,6 +49,7 @@ if (options.port):
cherrypy.config.update(settings)
# import du crans_ldap qu'il va bien
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
from ldap_crans_test import crans_ldap
cherrypy.log("settings : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"], "LDAP")
@ -93,16 +94,16 @@ class Intranet:
return {
'template':'accueil',
'values':{},
'stylesheets':['accueil.css'],
'stylesheets':['accueil.css'],
}
index.exposed= True
def info(self):
return {
'template':'info-diverses',
'values':{},
'stylesheets':['accueil.css'],
}
'template':'info-diverses',
'values':{},
'stylesheets':['accueil.css'],
}
info.exposed = True
@ -122,20 +123,6 @@ class Intranet:
else:
cherrypy._cputil._cp_on_http_error(status, message)
'''
def nounous(self):
return "coucou"
nounous.exposed= True
def test(self):
return {"quoi":cherrypy.request.path, "il_faut":cherrypy.config.configMap["/nounous"]["crans.droits"], "moi":cherrypy.session['droits']
}
test.exposed = True
def environment(self):
return cherrypy.config.configMap["global"]["server.environment"]
environment.exposed = True
'''
# ######################################################## #
# LOGIN MAISON #
@ -145,35 +132,33 @@ class Intranet:
#
def login(from_page = '', login = None, password = '', error_msg=''):
return {
'template':'login',
'values':{'login':login, 'password':password, 'from_page':from_page, 'message':error_msg},
'standalone':True
}
'template':'login',
'values':{'login':login, 'password':password, 'from_page':from_page, 'message':error_msg},
'standalone':True
}
#
# methode qui verifie le login
#
def verifLogin(login = '', password = ''):
message = None
if login != '' and password != '':
try:
globalLdap = cherrypy.config.configMap["global"]["crans_ldap"]
adh =globalLdap.search('uid=' + login)['adherent'][0]
try:
if login != '' and password != '':
cherrypy.session['LDAP'] = crans_ldap()
LDAP = cherrypy.session['LDAP']
adh = LDAP.search('uid=' + login)['adherent'][0]
if adh.checkPassword(password):
cherrypy.session['uid'] = login
cherrypy.session['session_key'] = True
cherrypy.session['droits'] = adh.droits()
cherrypy.session['LDAP'] = crans_ldap()
cherrypy.log("User logged in : %s" % cherrypy.session['uid'], "LOGIN")
return
else:
#print("bad password")
message = u"L'authentification a echoué."
except Exception, e:
#print(e)
raise Exception, "Bad password"
else:
message = u"L'authentification a echoué."
else:
#print("sth empty")
raise Exception, "Empty string"
except Exception, e:
cherrypy.log("%s (login:%s)" % (str(e), login), "LOGIN", 1)
message = u"L'authentification a echoué."
return message