Commit 4f3b212b authored by gdetrez's avatar gdetrez

correction du bug de login (j'espre)

darcs-hash:20061117140933-f46e9-af7e3b0bf4126861a3e9f9c1eb09227c3c6535c7.gz
parent b488b68d
......@@ -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
......
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# Factures #
# Factures
# ##################################################################################################### #
# Description: #
# Affiche la liste des factures et l'historique de dbits/crdits de l'adhrent. #
# Informations: #
# #
# Pages: #
# index:liste des factures #
# historique: historique des dbits/crdits #
# Description:
# Affiche la liste des factures et l'historique de dbits/crdits de l'adhrent.
# Informations:
#
# Pages:
# index:liste des factures
# historique: historique des dbits/crdits
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
class root:
__ldap = None
def __init__(self):
self.__ldap = cherrypy.config.configMap["global"]["crans_ldap"]
def index(self, message = '', error = ''):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
t = {}
t['message'] = message
t['error'] = error
......@@ -58,7 +55,7 @@ class root:
index.exposed = True
def historique(self):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
lst = [ x for x in adh.historique() if x.split(u' : ',1)[1].startswith(u'credit') or x.split(u' : ',1)[1].startswith(u'debit') ]
histLst = []
......@@ -84,7 +81,7 @@ class root:
def delFacture(self, no):
try:
# trrouver la factures
fact = self.__ldap.search('fid=' + no, 'w')['facture'][0]
fact = cherrypy.session['LDAP'].search('fid=' + no, 'w')['facture'][0]
#verifier qu'elle appartient bien a l'adherent
if not fact.proprietaire().mail() == cherrypy.session['uid']:
raise Exception, "Impossible de supprimer cette facture"
......
......@@ -19,6 +19,7 @@ class root:
#
def index(self, submit = None, fileList = None, newFile = None ):
data = {}
# on efface un eventuel objet impression existant
cherrypy.session['impression'] = None
if submit == "Envoyer":
try:
......@@ -108,7 +109,7 @@ class root:
try:
nouvPrix = cherrypy.session['impression'].changeSettings(papier=papier, couleurs=couleurs, agraphes=agrafes, recto_verso=recto_verso, copies=int(copies))
except Exception, e:
cherrypy.log("changeSettings (erreur): %s" % str(e), 'IMPRESSION', 1)
cherrypy.log("changeSettings : %s" % str(e), 'IMPRESSION', 1)
return {"erreur":str(e)}
return {'nouvPrix':nouvPrix}
changeSettings.exposed = True
......@@ -123,7 +124,7 @@ class root:
except crans.impression.SoldeInsuffisant:
return {"SoldeInsuffisant":1}
except Exception, e:
cherrypy.log("lancerImpression (erreur): %s" % str(e), 'IMPRESSION', 1)
cherrypy.log("lancerImpression : %s" % str(e), 'IMPRESSION', 1)
return {"erreur":str(e)}
cherrypy.log("impression", 'IMPRESSION')
return {'code':str(crans.impression.digicode.gen_code(cherrypy.session['uid'])) + "#"}
......
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# Machines
# ##################################################################################################### #
# Description:
# Affiche la liste des machies, les infons sur une machine et permet des modifications
# Informations:
#
# Pages:
# index:liste des machines + le reste (AJAX)
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
from time import strftime, localtime, time
# libraries crans
sys.path.append('/usr/scripts/gestion/')
from config_mail import MailConfig
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
from ldap_crans_test import *
# print("monCompte : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
# print("mesmachines : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
else:
from ldap_crans import *
# print("monCompte : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
# print("mesmachines : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
class root:
__ldap = None
def __init__(self):
self.__ldap = cherrypy.config.configMap["global"]["crans_ldap"]
def AJAXListeMachines(self):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
machines = []
for une_machine in adh.machines():
machineInfos = {}
......@@ -46,11 +51,11 @@ class root:
def AJAXMachineInfo(self, mid):
try:
machine = self.__ldap.search('mid=' + mid)['machine'][0]
machine = cherrypy.session['LDAP'].search('mid=' + mid)['machine'][0]
if machine.proprietaire().mail() != cherrypy.session['uid']:
raise Exception
# zamok -> pour tester l'affichage des ports, des alias
#machine = self.__ldap.search('mid=896')['machine'][0]
#machine = cherrypy.session['LDAP'].search('mid=896')['machine'][0]
machineInfos = {}
# nom, mac, mid, ip
machineInfos['nom'] = machine.nom()
......@@ -151,8 +156,8 @@ class root:
##########################
def AJAXChangerNom(self, mid, nouveauNom):
try:
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = self.__ldap.search('mid=' + mid, 'w')['machine'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = cherrypy.session['LDAP'].search('mid=' + mid, 'w')['machine'][0]
# tester si c'est bien la machine de l'adherent
if mach.proprietaire().compte() != cherrypy.session['uid']:
del adh, mach
......@@ -172,8 +177,8 @@ class root:
##########################
def AJAXchangerMAC(self, mid, nouvelleMAC):
try:
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = self.__ldap.search('mid=' + mid, 'w')['machine'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = cherrypy.session['LDAP'].search('mid=' + mid, 'w')['machine'][0]
# tester si c'est bien la machine de l'adherent
if mach.proprietaire().compte() != cherrypy.session['uid']:
del adh, mach
......@@ -194,8 +199,8 @@ class root:
##########################
def AJAXSupprimerMachine(self, mid):
try:
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = self.__ldap.search('mid=' + mid, 'w')['machine'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
mach = cherrypy.session['LDAP'].search('mid=' + mid, 'w')['machine'][0]
# tester si c'est bien la machine de l'adherent
if mach.proprietaire().compte() != cherrypy.session['uid']:
del adh, mach
......@@ -211,7 +216,7 @@ class root:
# machine:creation
##########################
def AJAXCreerMachine(self, nomNouvelleMachine, MACNouvelleMachine, typeNouvelleMachine):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
if typeNouvelleMachine=='fixe' and adh.droits() == [] and adh.machines_fixes() != []:
return {'error':'Vous avez deja une machine fixe. Vous ne pouvez ajouter que des machines WiFi.'}
try:
......
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# MonCompte
# ##################################################################################################### #
# Description:
#
# Informations:
#
# Pages:
#
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
# libraries crans
sys.path.append('/usr/scripts/gestion/')
from config_mail import MailConfig
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
from ldap_crans_test import *
# print("monCompte : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
......@@ -15,12 +27,6 @@ else:
class monCompte:
__ldap = None
def __init__(self):
self.__ldap = cherrypy.config.configMap["global"]["crans_ldap"]
def getCurrentAdministrativeYear(self):
'''
premiere partie de l''annee scolaire en cours
......@@ -43,7 +49,7 @@ class monCompte:
# l'adherent + les formulaires
#
def index(self, message = '', error = '', currentTab = 'mainTab'):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
t = {}
t['message'] = message
t['error'] = error
......@@ -120,7 +126,7 @@ class monCompte:
# via paypal
#
def rechargerCompteImpression(self, etape = '1', combien = None):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'])['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
if (etape == "1"): # Introduction
return {
'template' :'MonCompteRechargePaypal1',
......@@ -220,7 +226,7 @@ class monCompte:
# Adherent:nom
##########################
def changeNomAdherent(self, nouveauNom):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
try:
adh.nom(nouveauNom)
adh.save()
......@@ -245,7 +251,7 @@ class monCompte:
msg = 'Erreur, la confirmation ne correspond pas au nouveau mot de passe.'
return self.index(error=msg)
adh = self.__ldap.search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
if adh.checkPassword(ancienPassword):
adh.changePasswd(nouveauPassword1)
adh.save()
......@@ -263,7 +269,7 @@ class monCompte:
# Adherent:prenom
##########################
def changePrenomAdherent(self, nouveauPrenom):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
try:
adh.prenom(nouveauPrenom)
adh.save()
......@@ -278,7 +284,7 @@ class monCompte:
# Adherent:tel
##########################
def changeTelAdherent(self, nouveauTel):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'], 'w')['adherent'][0]
try:
adh.tel(nouveauTel)
adh.save()
......@@ -293,7 +299,7 @@ class monCompte:
# mail:alias:creation
##########################
def newAlias(self, alias):
adh = self.__ldap.search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
if adh.alias().__len__() >= 3:
return self.index(error=u"Vous avez plus de 2 alias. Demander à un câbleur pour en rajouter.")
try:
......@@ -328,7 +334,7 @@ class monCompte:
rewriteMailHeaders = True
try:
adh = self.__ldap.search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'],'w')['adherent'][0]
if forwarding_address!=None:
MailConfig(cherrypy.session['uid'], forward=forwarding_address, spam=spanTreatment)
adh.contourneGreylist(contourneGreylist)
......
......@@ -202,7 +202,7 @@ Crans.messages.setMessage('$error.replace("\'","\\\'")', 'errorMessage')
<ul class="tabbed_page">
<li class="centrer last">
<input type="reset" value="Reset" />
<input type="submit" name="mailSubmit" value="Soumettre" />
<input type="submit" value="Soumettre" />
</li>
</ul>
</form>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment