Seite 1 von 1

Modul Passwort ändern -> Passworteigenschaften vorgeben??

Verfasst: Mi 21. Feb 2007, 18:00
von bunny3112
Hallo,

habe das Modul Passwort ändern im Einsatz und wollte mal fragen, ob auch die Möglichkeit besteht in irgendeiner Form bestimmte Kriterien für das neue Passwort vorzugeben?

Bsp. Passwort soll mind. aus 6 Zeichen, Groß- und Kleinbuchstaben und Zahlen bestehen?

MfG
bunny3112

Verfasst: Mi 21. Feb 2007, 23:54
von HerrB
Ein Link zum Modul wäre nicht schlecht, vermutlich ist es meins.

Natürlich, Du kannst jede beliebige Prüfung einbauen.
a) Länge: strlen
b) Kleinbuchstaben: über einen regulären Ausdruck auf a-z prüfen
c) Großbuchstaben: über einen regulären Ausdruck auf A-Z prüfen
d) Zahlen: über einen regulären Ausdruck auf 0-9 prüfen

Wenn a), b), c) und d) = wahr, dann gut.

Lege doch mal vor, wir greifen dann unter die Arme.

Gruß
HerrB

Verfasst: Do 22. Feb 2007, 11:21
von schlaucher
Achtung, hier kommt eine Steilvorlage :wink:

Change Passwort überprüft nun:

Passwort Mindeslänge (einstellbar)
Passwort Maximallänge (einstellbar)
Passwort muss Kleinbuchstaben enthalten (einstellbar)
Passwort muss Großbuchstaben enthalten (einstellbar)
Passwort muss Zahlen enthalten (einstellbar)
Passwort muss Sonderzeichen enthalten (einstellbar)
Username und Passwort müssen unterschiedlich sein (fest)
Altes und neues Passwort müssen unterschiedlich sein (fest)


Input:

Code: Alles auswählen

/*********************************************** 
* CONTENIDO MODUL - INPUT 
* 
* Modulname   :     Change Password 1.1
* Author      :     HerrB 
* Copyright   :      
* Created     :     17.11.2005
* Modified    :     22-02-2007 (schlaucher) 
************************************************/ 

if ("CMS_VALUE[1]" == '') { 
   $pwdmin = 6; 
} else { 
   $pwdmin = "CMS_VALUE[1]"; 
} 

if ("CMS_VALUE[2]" == '') { 
   $pwdmax = 20; 
} else { 
   $pwdmax = "CMS_VALUE[2]"; 
} 

if ("CMS_VALUE[3]" == '') { 
   $pwdsmall = ''; 
} else { 
   $pwdsmall = ' checked'; 
} 

if ("CMS_VALUE[4]" == '') { 
   $pwdbig = ''; 
} else { 
   $pwdbig = ' checked'; 
} 

if ("CMS_VALUE[5]" == '') { 
   $pwdnum = ''; 
} else { 
   $pwdnum = ' checked'; 
} 

if ("CMS_VALUE[6]" == '') { 
   $pwdspecial = ''; 
} else { 
   $pwdspecial = ' checked'; 
} 

echo '<table cellspacing="0" cellpadding="10" border="0"><tr valign="top">'; 

echo '   <tr> 
            <td>'.mi18n("Password min. size:").'</td> 
            <td><input type="text" name="CMS_VAR[1]" value="'.$pwdmin.'" size="5" /></td></tr>'; 

echo '   <tr> 
            <td>'.mi18n("Password max. size").'</td> 
            <td><input type="text" name="CMS_VAR[2]" value="'.$pwdmax.'" size="5" /></td></tr>'; 

echo '   <tr> 
            <td>'.mi18n("Password must contain small characters").'</td> 
            <td><input type="checkbox" name="CMS_VAR[3]" value="yes" '.$pwdsmall.' /></td></tr>'; 

echo '   <tr> 
            <td>'.mi18n("Password must contain big characters").'</td> 
            <td><input type="checkbox" name="CMS_VAR[4]" value="yes" '.$pwdbig.' /></td></tr>'; 

echo '   <tr> 
            <td>'.mi18n("Password must contain numbers").'</td> 
            <td><input type="checkbox" name="CMS_VAR[5]" value="yes" '.$pwdnum.' /></td></tr>'; 

echo '   <tr> 
            <td>'.mi18n("Password must contain special characters").'</td> 
            <td><input type="checkbox" name="CMS_VAR[6]" value="yes" '.$pwdspecial.' /></td></tr>'; 

echo '</table>'; 
Output:

Code: Alles auswählen

<?php 
/*********************************************** 
* CONTENIDO MODUL - Output
* 
* Modulname   :     Change Password 1.1
* Author      :     HerrB 
* Copyright   :      
* Created     :     17.11.2005
* Modified    :     22-02-2007 (schlaucher) 
************************************************/ 

cInclude("classes", "class.frontend.users.php"); 

$frontendusers = new FrontendUserCollection; 
$frontendusers->select("idclient = '$client' AND username = '".urlencode($auth->auth[uname])."'"); 
if ($frontenduser = $frontendusers->next()) { 
   $idfrontend    = $frontenduser->get("idfrontenduser"); 

$pwdmin = "CMS_VALUE[1]";
$pwdmax = "CMS_VALUE[2]";
$pwdsmall = "CMS_VALUE[3]";
$pwdbig = "CMS_VALUE[4]";
$pwdnum = "CMS_VALUE[5]";
$pwdspecial = "CMS_VALUE[6]";

   $strMsg = ""; 

   if ($_REQUEST["action"] == "save") { 
   
      if ($_REQUEST["oldpw"] != "" || $_REQUEST["newpw1"] != "" || $_REQUEST["newpw2"] != "") { 
         if ($_REQUEST["oldpw"] == "") { 
            $strMsg = mi18n("If changing the password please provide the current password."); 
         } else if ($_REQUEST["newpw1"] == "" || $_REQUEST["newpw2"] == "") { 
            $strMsg = mi18n("If changing the password please specify new password and retype the new password to avoid typos."); 
         } else if (md5($_REQUEST["oldpw"]) != $frontenduser->get("password")) { 
            $strMsg = mi18n("Old password is wrong."); 
         } else if ($_REQUEST["newpw1"] != $_REQUEST["newpw2"]) { 
            $strMsg = mi18n("If changing the password the new password and the retyped new password must be equal."); 
         } else if (strlen($_REQUEST["newpw1"]) > $pwdmax ) { 
             $strMsg = mi18n("If changing the password please specify a new password with 24 characters max.."); 
         } else if (strlen($_REQUEST["newpw1"]) < $pwdmin ) { 
             $strMsg = mi18n("If changing the password please specify a new password with at least 6 characters."); 
         } else if ($_REQUEST["newpw1"] == $_REQUEST["oldpw"]) { 
             $strMsg = mi18n("If changing the password the old password and the new password must be different."); 
         } else if ($_REQUEST["newpw1"] == urlencode($auth->auth[uname])) { 
             $strMsg = mi18n("If changing the password the username and the new password must be different."); 
         } else if ($pwdsmall == 'yes' && !ereg ("[a-z]", $_REQUEST["newpw1"])) { 
             $strMsg = mi18n("Password must contain small characters."); 
         } else if ($pwdbig == 'yes' && !ereg ("[A-Z]", $_REQUEST["newpw1"])) { 
             $strMsg = mi18n("Password must contain big characters."); 
         } else if ($pwdnum == 'yes' && !ereg ("[0-9]", $_REQUEST["newpw1"])) { 
             $strMsg = mi18n("Password must contain numbers."); 
         } else if ($pwdspecial == 'yes' && ereg ("^[a-zA-Z0-9]+$",$_REQUEST["newpw1"])) { 
             $strMsg = mi18n("Password must contain special characters."); 
         } 
      } 
  
      if ($strMsg == "" && $_REQUEST["oldpw"] != "") { 
        $frontenduser->set("password", $_REQUEST["newpw1"]); 
        $frontenduser->store(); 
        $strMsg = mi18n("Changes has been saved."); 
      } else { 
        $strMsg = '<font color="#FF0000">'.$strMsg.'</font>'; 
      } 
   } 

   echo '<div id="form">';
   echo '<form name="frmProfile" method="post" action="'.$auth->url().'">',chr(10); 
   echo '  <table class="special" cellspacing="0"> ',chr(10); 
   echo '    <tr>',chr(10); 
   echo '      <td class="detail_headline" colspan="2"><h2>'.mi18n("Change Password:").'</h2></td>',chr(10); 
   echo '    </tr>',chr(10); 
   if ($strMsg != "") { 
      echo '    <tr>',chr(10); 
      echo '      <td class="detail_text" colspan="2">'.$strMsg.'</td>',chr(10); 
      echo '    </tr>',chr(10); 
   } 
   echo '    <tr>',chr(10); 
   echo '    <tr>',chr(10); 
   echo '      <td class="detail_text" style="width: 150px;">'.mi18n("Old password:").'</td>',chr(10); 
   echo '      <td class="detail_text"><input class="input" name="oldpw" type="password" size="24" maxlength="24"></td>',chr(10); 
   echo '    </tr>',chr(10); 
   echo '    <tr>',chr(10); 
   echo '      <td class="detail_text" style="width: 150px;">'.mi18n("New password:").'</td>',chr(10); 
   echo '      <td class="detail_text"><input class="input" name="newpw1" type="password" size="24" maxlength="24"></td>',chr(10); 
   echo '    </tr>',chr(10); 
   echo '    <tr>',chr(10); 
   echo '      <td class="detail_text" style="width: 150px;">'.mi18n("Retype password:").'</td>',chr(10); 
   echo '      <td class="detail_text"><input class="input" name="newpw2" type="password" size="24" maxlength="24"></td>',chr(10); 
   echo '    </tr>',chr(10); 
   echo '    <tr>',chr(10); 
   echo '      <td class="detail_text" colspan="2">&nbsp;</td>',chr(10); 
   echo '    </tr>',chr(10); 
   echo '    <tr>',chr(10); 
   echo '      <td class="detail_text" style="width: 100px;">&nbsp;</td>',chr(10); 
   echo '      <td class="detail_text"><input type="hidden" name="action" value="save"><input class="button" name="subscribe" type="submit" id="subscribe" value="'.mi18n("OK").'"></td>',chr(10); 
   echo '    </tr>',chr(10); 
   echo '  </table>',chr(10); 
   echo '</form></div>',chr(10); 
} 
?> 
Gruß
schlaucher

Verfasst: Do 22. Feb 2007, 15:05
von HerrB
Na wunderbar. Nach Module verschoben.

Gruß
HerrB

Probleme mit Passwort ändern

Verfasst: Fr 23. Feb 2007, 10:14
von bunny3112
Hallo,
zunächstmal danke für diese Prompte Umsetzung.

Hab natürlich das geänderte Modul sofort eingesetzt.. nur leider funktioniert es nicht. Egal was für ein Passwort ich eingebe, egal in welcher "Konstellation" kommt die Meldung, dass das Passwort max. 24 Zeichen haben darf

Gruss
bunny3112

Re: Probleme mit Passwort ändern

Verfasst: Fr 23. Feb 2007, 10:47
von schlaucher
bunny3112 hat geschrieben:Hallo,
zunächstmal danke für diese Prompte Umsetzung.

Hab natürlich das geänderte Modul sofort eingesetzt.. nur leider funktioniert es nicht. Egal was für ein Passwort ich eingebe, egal in welcher "Konstellation" kommt die Meldung, dass das Passwort max. 24 Zeichen haben darf

Gruss
bunny3112
Die Maximallänge wird hier geprüft:

Code: Alles auswählen

else if (strlen($_REQUEST["newpw1"]) > $pwdmax )  {
$strMsg = mi18n("If changing the password please specify a new password with 24 characters max.."); 
}
ersetze das mal durch:

Code: Alles auswählen

else if (strlen($_REQUEST["newpw1"]) > $pwdmax )  {
echo 'PWD: '.strlen($_REQUEST["newpw1"].' | Max: '.$pwdmax.'<br>';
$strMsg = mi18n("If changing the password please specify a new password with 24 characters max.."); 
}
Damit werden die beiden Werte ausgegeben

Gruß
schlaucher

will noch immer nicht

Verfasst: Fr 23. Feb 2007, 11:16
von bunny3112
..sobald ich die Angaben über den Editor ergänze, geht bei contenido das rote Lämpchen an..

Re: will noch immer nicht

Verfasst: Fr 23. Feb 2007, 11:23
von schlaucher
bunny3112 hat geschrieben:..sobald ich die Angaben über den Editor ergänze, geht bei contenido das rote Lämpchen an..
sorry, Klammer vergessen:

Code: Alles auswählen

echo 'PWD: '.strlen($_REQUEST["newpw1"]).' | Max: '.$pwdmax.'<br>';

klappt immer noch nicht..

Verfasst: Fr 9. Mär 2007, 23:36
von bunny3112
Hallo,

habe die fehlende Klammer ergänzt, bekomme aber immer noch die gleiche Fehlermeldung. Vielleicht noch ne Idee woran es liegen könnte?

MfG
Bunny

Verfasst: Mo 12. Mär 2007, 20:05
von Dodger77
Hast du denn alles richtig konfiguriert? Bei meinen Tests wurde immer dann die von dir genannte Fehlermeldung ausgegeben, wenn ich keine Angaben zur maximalen Länge des Passworts vorgenommen hatte.