[wiki/action/crans_newaccount,wiki/creer_compte_wiki] Petites modifications pour pouvoir créer des comptes depuis l'intranet2
This commit is contained in:
parent
89adc33b29
commit
d919134329
2 changed files with 5 additions and 4 deletions
|
@ -24,6 +24,7 @@ def do_register(request):
|
||||||
authorized_ips = [
|
authorized_ips = [
|
||||||
'2a01:240:fe3d:4:2248cff:fe44:3b70', #vo.v6
|
'2a01:240:fe3d:4:2248cff:fe44:3b70', #vo.v6
|
||||||
'2a01:240:fe3d:4:219:bbff:fe3c:4f76', #zamok.v6
|
'2a01:240:fe3d:4:219:bbff:fe3c:4f76', #zamok.v6
|
||||||
|
'2a01:240:fe3d:4:0:6cff:fe69:6921', #o2.v6
|
||||||
]
|
]
|
||||||
|
|
||||||
if request.remote_addr not in authorized_ips:
|
if request.remote_addr not in authorized_ips:
|
||||||
|
|
|
@ -29,7 +29,7 @@ encoding = "utf-8"
|
||||||
# Utilisateur qui lance le script
|
# Utilisateur qui lance le script
|
||||||
user = getuser()
|
user = getuser()
|
||||||
|
|
||||||
def send(msg):
|
def send(msg, user=user):
|
||||||
msg['From'] = '%s@crans.org' % user
|
msg['From'] = '%s@crans.org' % user
|
||||||
msg['To'] = ','.join(bugmail)
|
msg['To'] = ','.join(bugmail)
|
||||||
msg['User-Agent'] = 'creer_compte_wiki.py'
|
msg['User-Agent'] = 'creer_compte_wiki.py'
|
||||||
|
@ -38,7 +38,7 @@ def send(msg):
|
||||||
smtp.sendmail('%s@crans.org' % user, bugmail, msg.as_string())
|
smtp.sendmail('%s@crans.org' % user, bugmail, msg.as_string())
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
|
|
||||||
def creer_compte(nom, mdp, email):
|
def creer_compte(nom, mdp, email, user=user):
|
||||||
form = {'action': 'crans_newaccount',
|
form = {'action': 'crans_newaccount',
|
||||||
'name': nom.encode(encoding),
|
'name': nom.encode(encoding),
|
||||||
'password': mdp,
|
'password': mdp,
|
||||||
|
@ -55,7 +55,7 @@ def creer_compte(nom, mdp, email):
|
||||||
if 'created' in data:
|
if 'created' in data:
|
||||||
msg = MIMEText(bugreport.encode(encoding) % form, 'plain', encoding)
|
msg = MIMEText(bugreport.encode(encoding) % form, 'plain', encoding)
|
||||||
msg['Subject'] = "creer_compte_wiki.py: success"
|
msg['Subject'] = "creer_compte_wiki.py: success"
|
||||||
send(msg)
|
send(msg, user)
|
||||||
return u"Compte %s créé avec succès !" % nom, False
|
return u"Compte %s créé avec succès !" % nom, False
|
||||||
elif 'nonunique name' in data:
|
elif 'nonunique name' in data:
|
||||||
return u"Le compte %s existe déjà !" % nom, True
|
return u"Le compte %s existe déjà !" % nom, True
|
||||||
|
@ -82,7 +82,7 @@ correctement configur
|
||||||
msg['Subject'] = '[Bugreport] creer_compte_wiki.py: creer_compte'
|
msg['Subject'] = '[Bugreport] creer_compte_wiki.py: creer_compte'
|
||||||
msg.attach(txt)
|
msg.attach(txt)
|
||||||
msg.attach(html)
|
msg.attach(html)
|
||||||
send(msg)
|
send(msg, user)
|
||||||
return coul(u"Erreur inconnue\n", "rouge") + \
|
return coul(u"Erreur inconnue\n", "rouge") + \
|
||||||
u"Un rapport de bug a été automatiquement envoyé. Réessayez plus tard."
|
u"Un rapport de bug a été automatiquement envoyé. Réessayez plus tard."
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue