|
|
@@ -116,6 +116,7 @@ def edit(request):
|
|
|
utente = Utente()
|
|
|
utente.pin = str(randint(100000,999999))
|
|
|
utente.azienda = data['azienda']
|
|
|
+ utente.azienda.forzanuovapassword
|
|
|
else:
|
|
|
try:
|
|
|
utente = Utente.objects.get(pk=data['UserEditId'])
|
|
|
@@ -152,6 +153,7 @@ def edit(request):
|
|
|
utente.datanascita = fu.cleaned_data['datanascita']
|
|
|
utente.mail = fu.cleaned_data['mail'].lower()
|
|
|
utente.pin = fu.cleaned_data['pin']
|
|
|
+ utente.primologin = fu.cleaned_data['primologin']
|
|
|
print('utente id',utente.id,utente.nome)
|
|
|
setLog(7,utente=utente)
|
|
|
utente.save()
|
|
|
@@ -185,6 +187,7 @@ def edit(request):
|
|
|
tmp['luogonascita'] = utente.luogonascita
|
|
|
tmp['mail'] = utente.mail
|
|
|
tmp['pin'] = utente.pin
|
|
|
+ tmp['primologin'] = utente.primologin
|
|
|
print("tmp su request non valida",tmp)
|
|
|
data['utente'] = formUtente(tmp)
|
|
|
|
|
|
@@ -270,7 +273,8 @@ def updatePasswordFromLogin(request,uuid):
|
|
|
cfisc = formupdatepasswordlogin.cleaned_data.get('cfisc')
|
|
|
pin1 = formupdatepasswordlogin.cleaned_data.get('pin1')
|
|
|
pin2 = formupdatepasswordlogin.cleaned_data.get('pin2')
|
|
|
- print('stato',cfisc,pin1,pin2)
|
|
|
+ uuidl = formupdatepasswordlogin.cleaned_data.get('uuid')
|
|
|
+ print('stato',cfisc,pin1,pin2,uuidl)
|
|
|
|
|
|
a = None
|
|
|
d = None
|
|
|
@@ -292,35 +296,42 @@ def updatePasswordFromLogin(request,uuid):
|
|
|
print('informazione non trovata tra i login amministratotore')
|
|
|
|
|
|
print('record',a.id,a.nome,a.uuid,d)
|
|
|
+
|
|
|
if d == 'u':
|
|
|
print('utente',a.codicefiscale)
|
|
|
if d == 'a':
|
|
|
print('amministratore',a.login)
|
|
|
|
|
|
- a.pin = pin1
|
|
|
- a.uuid = ""
|
|
|
- a.save()
|
|
|
+ if uuidl == a.uuid:
|
|
|
+ print('uuid corrisponde',uuidl,uuid)
|
|
|
+ a.pin = pin1
|
|
|
+ a.uuid = ""
|
|
|
+ a.lostpin = False
|
|
|
+ a.save()
|
|
|
|
|
|
- ### comunicazioni ###
|
|
|
- if len(a.mail) > 0:
|
|
|
- comunicazione = None
|
|
|
- try:
|
|
|
- comunicazione = Comunicazione.objects.get(pk=5)
|
|
|
- except Comunicazione.DoesNotExist as dne:
|
|
|
- print('comunicazione non valida',dne)
|
|
|
- if comunicazione:
|
|
|
- sm = ServizioMail(debug=True)
|
|
|
- sm.set_mailfrom=comunicazione.mittente
|
|
|
- sm.add_to(a.mail)
|
|
|
-
|
|
|
- sm.set_soggetto(comunicazione.soggetto)
|
|
|
- sm.set_corpo(comunicazione.corpo)
|
|
|
-
|
|
|
- sm_data = dict()
|
|
|
- sm_data['utente'] = a
|
|
|
- sm.set_data(sm_data)
|
|
|
- sm.send()
|
|
|
- ### comunicazioni ###
|
|
|
+ ### comunicazioni ###
|
|
|
+ if len(a.mail) > 0:
|
|
|
+ comunicazione = None
|
|
|
+ try:
|
|
|
+ comunicazione = Comunicazione.objects.get(pk=5)
|
|
|
+ except Comunicazione.DoesNotExist as dne:
|
|
|
+ print('comunicazione non valida',dne)
|
|
|
+ if comunicazione:
|
|
|
+ sm = ServizioMail(debug=True)
|
|
|
+ sm.set_mailfrom=comunicazione.mittente
|
|
|
+ sm.add_to(a.mail)
|
|
|
+
|
|
|
+ sm.set_soggetto(comunicazione.soggetto)
|
|
|
+ sm.set_corpo(comunicazione.corpo)
|
|
|
+
|
|
|
+ sm_data = dict()
|
|
|
+ sm_data['utente'] = a
|
|
|
+ sm.set_data(sm_data)
|
|
|
+ sm.send()
|
|
|
+ ### comunicazioni ###
|
|
|
+ else:
|
|
|
+ print('form non valida, errore uuid')
|
|
|
+ data['informazione'] = formUpdatePasswordLogin(request.POST)
|
|
|
|
|
|
return HttpResponseRedirect(reverse("login:start"))
|
|
|
else:
|
|
|
@@ -337,3 +348,98 @@ def updatePasswordFromLogin(request,uuid):
|
|
|
print(data)
|
|
|
|
|
|
return render(request,'utente.edit.password.login.html',data)
|
|
|
+
|
|
|
+def forceUpdatePassword(request,uuid):
|
|
|
+ '''
|
|
|
+ la form che segue, serve per aggiornare la propria password/pin dal login
|
|
|
+ '''
|
|
|
+ data = dict()
|
|
|
+ data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
+ data['uuid'] = uuid
|
|
|
+ print('uuid',uuid)
|
|
|
+
|
|
|
+ if request.method == 'POST':
|
|
|
+ print(request.POST)
|
|
|
+ formupdatepasswordlogin = formUpdatePasswordPrimoLogin(request.POST)
|
|
|
+ if formupdatepasswordlogin.is_valid():
|
|
|
+ cfisc = formupdatepasswordlogin.cleaned_data.get('cfisc')
|
|
|
+ pin0 = formupdatepasswordlogin.cleaned_data.get('pin0')
|
|
|
+ pin1 = formupdatepasswordlogin.cleaned_data.get('pin1')
|
|
|
+ pin2 = formupdatepasswordlogin.cleaned_data.get('pin2')
|
|
|
+ print('stato',cfisc,pin1,pin2)
|
|
|
+
|
|
|
+ a = None
|
|
|
+ d = None
|
|
|
+ # 1 tentativo su codice fiscale
|
|
|
+ try:
|
|
|
+ a = Utente.objects.get(codicefiscale=cfisc.upper())
|
|
|
+ d = 'u'
|
|
|
+ except Utente.DoesNotExist as dne:
|
|
|
+ print('informazione non trovata tra i codici fiscali utente')
|
|
|
+ try:
|
|
|
+ a = Utente.objects.get(mail=cfisc.lower())
|
|
|
+ d = 'u'
|
|
|
+ except Utente.DoesNotExist as dne:
|
|
|
+ print('informazione non trovata tra le email')
|
|
|
+ try:
|
|
|
+ a = Amministratore.objects.get(login=cfisc.lower())
|
|
|
+ d = 'a'
|
|
|
+ except Amministratore.DoesNotExist as dne:
|
|
|
+ print('informazione non trovata tra i login amministratotore')
|
|
|
+
|
|
|
+ oldpwd = False
|
|
|
+ print('record',a.id,a.nome,a.uuid,d)
|
|
|
+ if d == 'u':
|
|
|
+ print('utente',a.codicefiscale)
|
|
|
+ if a.pin == pin0:
|
|
|
+ oldpwd = True
|
|
|
+ print('verificata la vecchia password')
|
|
|
+ if d == 'a':
|
|
|
+ print('amministratore',a.login)
|
|
|
+
|
|
|
+ if oldpwd:
|
|
|
+ print('password vecchia ok')
|
|
|
+ a.pin = pin1
|
|
|
+ a.uuid = ""
|
|
|
+ a.primologin = False
|
|
|
+ a.lostpassword = False
|
|
|
+ a.save()
|
|
|
+
|
|
|
+ ### comunicazioni ###
|
|
|
+ if len(a.mail) > 0:
|
|
|
+ comunicazione = None
|
|
|
+ try:
|
|
|
+ comunicazione = Comunicazione.objects.get(pk=5)
|
|
|
+ except Comunicazione.DoesNotExist as dne:
|
|
|
+ print('comunicazione non valida',dne)
|
|
|
+ if comunicazione:
|
|
|
+ sm = ServizioMail(debug=True)
|
|
|
+ sm.set_mailfrom=comunicazione.mittente
|
|
|
+ sm.add_to(a.mail)
|
|
|
+ sm.set_soggetto(comunicazione.soggetto)
|
|
|
+ sm.set_corpo(comunicazione.corpo)
|
|
|
+
|
|
|
+ sm_data = dict()
|
|
|
+ sm_data['utente'] = a
|
|
|
+ sm.set_data(sm_data)
|
|
|
+ sm.send()
|
|
|
+ ### comunicazioni ###
|
|
|
+ return HttpResponseRedirect(reverse("login:start"))
|
|
|
+ else:
|
|
|
+ print('form not valid nella validazione vecchia password',a.pin,pin0)
|
|
|
+ data['informazione'] = formUpdatePasswordPrimoLogin(request.POST)
|
|
|
+ else:
|
|
|
+ print('form not valid')
|
|
|
+ data['informazione'] = formUpdatePasswordPrimoLogin(request.POST)
|
|
|
+ else:
|
|
|
+ print('request non valida', request.POST)
|
|
|
+ tmp = dict()
|
|
|
+ tmp['cfisc'] = ""
|
|
|
+ tmp['uuid'] = uuid
|
|
|
+ tmp['pin0'] = ""
|
|
|
+ tmp['pin1'] = ""
|
|
|
+ tmp['pin2'] = ""
|
|
|
+ data['informazione'] = formUpdatePasswordPrimoLogin(tmp)
|
|
|
+ print(data)
|
|
|
+
|
|
|
+ return render(request,'utente.edit.password.primologin.html',data)
|