Explorar o código

reso effettivo il cambio password utente

mauro hai 1 mes
pai
achega
5fe667f191
Modificáronse 4 ficheiros con 55 adicións e 47 borrados
  1. BIN=BIN
      db/db.sqlite3
  2. 27 21
      utente/forms.py
  3. 1 2
      utente/templates/utente.edit.password.login.html
  4. 27 24
      utente/views.py

BIN=BIN
db/db.sqlite3


+ 27 - 21
utente/forms.py

@@ -62,16 +62,30 @@ class formUpdatePasswordLogin(forms.Form):
     self.fields['pin2'] = forms.CharField(required=True)
 
   def clean_pin1(self):
-    print(dir(self))
+    a = None
+    d = None
+    # 1 tentativo su utente
+    try: 
+      a = Utente.objects.get(uuid=self.data['uuid'])
+      d = 'u'
+    except Utente.DoesNotExist as dne:
+      print('informazione non trovata tra gli utenti')
+      try:
+        a = Amministratore.objects.get(uuid=self.data['uuid'])
+        d = 'a'
+      except Amministratore.DoesNotExist as dne:
+        print('informazione non trovata tra i login amministratotore')
+
+    if not a:
+      raise forms.ValidationError("UUID Non Validato")
+
+
     # validazione password
     if self.data['pin1'] != self.data['pin2']:
       # password non corrispondente
       raise forms.ValidationError("Le due password devono essere uguali")
 
-    if self.data['pin1'] == self.data['cfisc']:
-      # nome uguale a login
-      raise forms.ValidationError("La password non puo' essere uguale al login")
-  
+
     if len(self.data['pin1']) < int(getConfig('PasswordMin')):
       # lunghezza minima della password
       raise forms.ValidationError("Password troppo corta")
@@ -81,26 +95,18 @@ class formUpdatePasswordLogin(forms.Form):
   def clean_uuid(self):
       a = None
       d = None
-      login = self.data['cfisc']
-      print('login intercettato',login)
-      # 1 tentativo su codice fiscale
+      # 1 tentativo su utente
       try: 
-        a = Utente.objects.get(codicefiscale=login.upper())
+        a = Utente.objects.get(uuid=self.data['uuid'])
         d = 'u'
       except Utente.DoesNotExist as dne:
-        print('informazione non trovata tra i codici fiscali utente')
+        print('informazione non trovata tra gli utenti')
         try:
-          a = Utente.objects.get(mail=login.lower())
-          d = 'u'
-        except Utente.DoesNotExist as dne:
-          print('informazione non trovata tra le email')
-          try:
-            a = Amministratore.objects.get(login=login.lower())
-            d = 'a'
-          except Amministratore.DoesNotExist as dne:
-            print('informazione non trovata tra i login amministratotore')
-        except Utente.MultipleObjectsReturned as mor:
-          print('oggetti multipli trovati',mor)
+          a = Amministratore.objects.get(uuid=self.data['uuid'])
+          d = 'a'
+        except Amministratore.DoesNotExist as dne:
+          print('informazione non trovata tra i login amministratotore')
+
       if not a:
         raise forms.ValidationError("UUID Non Validato")
       else:

+ 1 - 2
utente/templates/utente.edit.password.login.html

@@ -25,7 +25,7 @@
   </div>
 
   <div class="container text-center">
-    <p class="lead">Per accedere utilizzare il proprio codice fiscale o il proprio login name insieme al Pin o alla Password assegnata.</p>
+    <p class="lead">Digitare la nuova password e ripeterla nel campo sottostante.</p>
   </div>
 
   <div>
@@ -37,7 +37,6 @@
     <form name='UpdatePassword' method='post' class='form-container card p-3 bg-light'>
       {% csrf_token %}
     <div class='form-outline mb-3'>
-	    <input type='hidden' class='form-control' id='cfisc' name='cfisc' value="{{ informazione.cfisc.value }}" readonly>
       <input type='hidden'  class='form-control' id='uuid' name='uuid' value="{{ informazione.uuid.value }}" readonly>
     <div>
     <div class='form-outline mb-3 {% if "pin1" in informazione.errors %} text-danger {% endif %}'>

+ 27 - 24
utente/views.py

@@ -598,36 +598,40 @@ def updatePasswordFromLogin(request,uuid):
   data['uuid'] = uuid
   print('uuid',uuid)
 
+  a = None
+  d = None
+  # 1 tentativo su codice fiscale
+  try: 
+    a = Utente.objects.get(uuid=uuid)
+    d = 'u'
+  except Utente.DoesNotExist as dne:
+    print('informazione non trovata tra gli utente')
+    try:
+      a = Amministratore.objects.get(uuid=uuid)
+      d = 'a'
+    except Amministratore.DoesNotExist as dne:
+      print('informazione non trovata tra i login amministratotore')
+
+
+  if d == 'u':
+    print('utente',a.codicefiscale)
+  elif d == 'a':
+    print('amministratore',a.login)
+  else:
+    print("Furbata: l'uuid non si trova",uuid)
+    return HttpResponseRedirect(reverse("login:start"))
+
+  print('record',a.id,a.nome,a.uuid,d)
+
+  # ora effettuiamo il controllo
   if request.method == 'POST':
     print('updatePasswordFromLogin: un tasto è stato premuto')
     formupdatepasswordlogin = formUpdatePasswordLogin(request.POST)
     if formupdatepasswordlogin.is_valid():
-      cfisc = formupdatepasswordlogin.cleaned_data.get('cfisc')
       pin1 = formupdatepasswordlogin.cleaned_data.get('pin1')
       pin2 = formupdatepasswordlogin.cleaned_data.get('pin2')
       uuidl = formupdatepasswordlogin.cleaned_data.get('uuid')
-      print('stato',cfisc,pin1,pin2,uuidl)
-
-      a = None
-      d = None
-      # 1 tentativo su codice fiscale
-      try: 
-        a = Utente.objects.get(uuid=uuidl)
-        d = 'u'
-      except Utente.DoesNotExist as dne:
-        print('informazione non trovata tra i codici fiscali utente')
-        try:
-          a = Amministratore.objects.get(uuid=uuidl)
-          d = 'a'
-        except Amministratore.DoesNotExist as dne:
-          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)
+      print('stato',pin1,pin2,uuidl)
 
       if uuidl == a.uuid:
         print('uuid corrisponde',uuidl,uuid)
@@ -667,7 +671,6 @@ def updatePasswordFromLogin(request,uuid):
   else:
     print('request non valida', request.POST)
     tmp = dict()
-    tmp['cfisc'] = ""
     tmp['uuid'] = uuid
     tmp['pin1'] = ""
     tmp['pin2'] = ""