--- passwd 5 Jan 2003 02:38:11 -0000 1.11 +++ passwd 23 Jun 2003 09:49:51 -0000 @@ -47,6 +47,7 @@ use CGI::Carp qw(fatalsToBrowser); use CGI; use TWiki; +use TWiki::Htpasswd; if( $TWiki::OS eq "WINDOWS" ) { require MIME::Base64; @@ -83,8 +84,9 @@ return; } - # check if user entry exists - if( ( $wikiName ) && (! htpasswdExistUser( $wikiName ) ) ) { + # find user entry, display the warning if it doesn't exist + my $oldEntry = &TWiki::Htpasswd::findEntry( $wikiName ); + if( ! $oldEntry ) { # PTh 20 Jun 2000: changed to getOopsUrl $url = &TWiki::getOopsUrl( $webName, $topic, "oopsnotwikiuser", $wikiName ); TWiki::redirect( $query, $url ); @@ -98,7 +100,11 @@ return; } - my $theCryptPassword = &htpasswdGeneratePasswd( $wikiName, $passwordA ); + # generate the new encrypted password and the password entry + my $newEncryptedPassword = + &TWiki::Htpasswd::encodePassword( $wikiName, $passwordA ); + my $newEntry = + &TWiki::Htpasswd::makeEntry( $wikiName, $newEncryptedPassword ); my $change = $query->param( "change" ) || ""; @@ -115,10 +121,7 @@ } # check password - my $oldcrypt = htpasswdReadPasswd( $wikiName ); - - my $pw = htpasswdCheckPasswd( $oldpassword, $oldcrypt ); - if( ! $pw ) { + if( ! &TWiki::Htpasswd::verifyPassword( $oldEntry, $oldpassword ) ) { # NO - wrong old password $url = &TWiki::getOopsUrl( $webName, $topic, "oopswrongpassword"); TWiki::redirect( $query, $url ); @@ -126,8 +129,7 @@ } # OK - password may be changed - my $oldCryptPassword = "$wikiName\:$oldcrypt"; - htpasswdAddUser( $oldCryptPassword, $theCryptPassword ); + &TWiki::Htpasswd::replaceEntry( $oldEntry, $newEntry ); # OK - password changed $url = &TWiki::getOopsUrl( $webName, $topic, "oopschangepasswd" ); @@ -138,13 +140,16 @@ # r e s e t # and finally display the reset password page - $url = &TWiki::getOopsUrl( $webName, $wikiName, "oopsresetpasswd", $theCryptPassword ); + $url = &TWiki::getOopsUrl( + $webName, $wikiName, "oopsresetpasswd", + "$wikiName:$newEncryptedPassword" ); TWiki::redirect( $query, $url ); return; } } +# pvgoran: this function is no longer needed. # ========================= sub htpasswdCheckPasswd { @@ -171,6 +176,7 @@ return ""; } +# pvgoran: this function is no longer needed. # ========================= sub htpasswdReadPasswd { @@ -187,6 +193,7 @@ return ""; } +# pvgoran: this function is no longer needed. # ========================= sub htpasswdExistUser { @@ -203,6 +210,7 @@ return ""; } +# pvgoran: this function is no longer needed. # ========================= sub htpasswdGeneratePasswd { @@ -225,6 +233,7 @@ return "$user\:$passwdcrypt"; } +# pvgoran: this function is no longer needed. # ========================= sub htpasswdAddUser {