Changeset 8408


Ignore:
Timestamp:
08/03/10 02:56:39 (22 months ago)
Author:
GeorgeClark
Message:

Item2484: Create missing .htpasswd file if needed
Item1701: Add reset password functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x00/core/lib/Foswiki/Users/ApacheHtpasswdUser.pm

    r2689 r8408  
    11# See bottom of file for license and copyright information 
    22package Foswiki::Users::ApacheHtpasswdUser; 
    3 use base 'Foswiki::Users::Password'; 
    4  
    5 use Apache::Htpasswd; 
     3use strict; 
     4use warnings; 
     5 
     6use Foswiki::Users::Password (); 
     7our @ISA = ('Foswiki::Users::Password'); 
     8 
     9use Apache::Htpasswd (); 
    610use Assert; 
    7 use strict; 
    8 use Foswiki::Users::Password; 
    911use Error qw( :try ); 
    1012 
     
    2830 
    2931    my $this = $class->SUPER::new($session); 
    30     $this->{apache} = 
    31       new Apache::Htpasswd( { passwdFile => $Foswiki::cfg{Htpasswd}{FileName} } ); 
     32    $this->{apache} = new Apache::Htpasswd( 
     33        { passwdFile => $Foswiki::cfg{Htpasswd}{FileName} } ); 
     34    unless ( -e $Foswiki::cfg{Htpasswd}{FileName} ) { 
     35        # apache doesn't create the file, so need to init it 
     36        my $F; 
     37        open( $F, '>', $Foswiki::cfg{Htpasswd}{FileName} ) || die $!; 
     38        print $F ""; 
     39        close($F); 
     40    } 
    3241 
    3342    return $this; 
     
    125134    ASSERT($login) if DEBUG; 
    126135 
    127     if ( defined($oldPassU) ) { 
     136    if ( defined($oldPassU) && $oldPassU ne '1') { 
    128137        my $ok = 0; 
    129138        try { 
     
    139148    my $added = 0; 
    140149    try { 
    141         $added = $this->{apache}->htpasswd( $login, $newPassU, $oldPassU ); 
     150        if ( defined($oldPassU) && $oldPassU eq '1') { 
     151            $added = $this->{apache}->htpasswd( $login, $newPassU, { 'overwrite' => 1} ); 
     152        } else { 
     153            $added = $this->{apache}->htpasswd( $login, $newPassU, $oldPassU ); 
     154        } 
    142155        $this->{error} = undef; 
    143156    } 
     
    191204 
    1922051; 
    193 __DATA__ 
    194 # Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/ 
    195 # 
    196 # Copyright (C) 2008-2009 Foswiki Contributors. All Rights Reserved. 
    197 # Foswiki Contributors are listed in the AUTHORS file in the root 
    198 # of this distribution. NOTE: Please extend that file, not this notice. 
    199 # 
    200 # Additional copyrights apply to some or all of the code in this 
    201 # file as follows: 
    202 # 
    203 # Copyright (C) 2004-2007 TWiki Contributors. All Rights Reserved. 
    204 # TWiki Contributors are listed in the AUTHORS file in the root 
    205 # of this distribution. NOTE: Please extend that file, not this notice. 
    206 # 
    207 # This program is free software; you can redistribute it and/or 
    208 # modify it under the terms of the GNU General Public License 
    209 # as published by the Free Software Foundation; either version 2 
    210 # of the License, or (at your option) any later version. For 
    211 # more details read LICENSE in the root of this distribution. 
    212 # 
    213 # This program is distributed in the hope that it will be useful, 
    214 # but WITHOUT ANY WARRANTY; without even the implied warranty of 
    215 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
    216 # 
    217 # As per the GPL, removal of this notice is prohibited. 
     206__END__ 
     207Foswiki - The Free and Open Source Wiki, http://foswiki.org/ 
     208 
     209Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors 
     210are listed in the AUTHORS file in the root of this distribution. 
     211NOTE: Please extend that file, not this notice. 
     212 
     213Additional copyrights apply to some or all of the code in this 
     214file as follows: 
     215 
     216Copyright (C) 2004-2007 TWiki Contributors. All Rights Reserved. 
     217TWiki Contributors are listed in the AUTHORS file in the root 
     218of this distribution. 
     219 
     220This program is free software; you can redistribute it and/or 
     221modify it under the terms of the GNU General Public License 
     222as published by the Free Software Foundation; either version 2 
     223of the License, or (at your option) any later version. For 
     224more details read LICENSE in the root of this distribution. 
     225 
     226This program is distributed in the hope that it will be useful, 
     227but WITHOUT ANY WARRANTY; without even the implied warranty of 
     228MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
     229 
     230As per the GPL, removal of this notice is prohibited. 
Note: See TracChangeset for help on using the changeset viewer.