--- installpasswd 5 Jan 2003 01:46:45 -0000 1.8 +++ installpasswd 23 Jun 2003 09:52:07 -0000 @@ -39,6 +39,7 @@ use CGI::Carp qw(fatalsToBrowser); use CGI; use TWiki; +use TWiki::Htpasswd; $query= new CGI; @@ -79,11 +80,13 @@ TWiki::redirect( $query, $url ); return; } + + my ( $installWikiName, $installEncryptedPassword ); # TODO: I18N fix here once basic auth problem with 8-bit user names is # solved - if ( $theCryptPassword =~ m/^([A-Z][a-zA-Z]+[A-Z][a-zA-Z]*)\:.{13}$/ ) { - $wikiName = $1; + if ( $theCryptPassword =~ m/^([A-Z][a-zA-Z]+[A-Z][a-zA-Z]*)\:(.*)$/ ) { + ( $installWikiName, $installEncryptedPassword ) = ( $1, $2 ); } else { # bad format $url = &TWiki::getOopsUrl( $webName, $topic, "oopsbadpwformat", $theCryptPassword); @@ -91,19 +94,18 @@ 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( $installWikiName ); + if( !$oldEntry ){ # PTh 20 Jun 2000: changed to getOopsUrl $url = &TWiki::getOopsUrl( $webName, $topic, "oopsnotwikiuser", $wikiName ); TWiki::redirect( $query, $url ); return; } - # old password - my $oldcrypt = htpasswdReadPasswd( $wikiName ); - # OK - password may be changed - my $oldCryptPassword = "$wikiName\:$oldcrypt"; - htpasswdAddUser( $oldCryptPassword, $theCryptPassword ); + my $newEntry = &TWiki::Htpasswd::makeEntry( + $installWikiName, $installEncryptedPassword ); + &TWiki::Htpasswd::replaceEntry( $oldEntry, $newEntry ); # OK - password changed $url = &TWiki::getOopsUrl( $webName, $topic, "oopschangepasswd" ); @@ -112,6 +114,7 @@ } #========================= +# pvgoran: this function is no longer needed. sub htpasswdReadPasswd { my ( $user ) = @_; @@ -127,6 +130,7 @@ return ""; } +# pvgoran: this function is no longer needed. sub htpasswdExistUser { my ( $user ) = @_; @@ -142,6 +146,7 @@ return ""; } +# pvgoran: this function is no longer needed. sub htpasswdAddUser { my ( $oldUserEntry, $newUserEntry ) = @_;