Ignore:
Timestamp:
04/26/09 17:46:06 (15 years ago)
Author:
nanardon
Message:
  • add set_password() - specific because crypt management
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm

    r42 r55  
    189189} 
    190190 
     191=head2 set_password($password) 
     192 
     193Set the password into the database, $password is the clear version 
     194of the password. 
     195 
     196This function store it into userPassword canonical field if supported 
     197using crypt unix and md5 algorythm (crypt md5), the salt is 8 random 
     198caracters. 
     199 
     200The base driver should override it if another encryption is need. 
     201 
     202=cut 
     203 
     204sub set_password { 
     205    my ($self, $clear_pass) = @_; 
     206    if (my $field = $self->base->get_field_name($self->type, 'userPassword')) { 
     207        my @salt_char = (('a' .. 'z'), ('A' .. 'Z'), (0 .. 9), '/', '.'); 
     208        my $salt = join('', map { $salt_char[rand(scalar(@salt_char))] } (1 .. 8)); 
     209        $self->set_field($field, crypt($clear_pass, $salt)); 
     210    } 
     211} 
     212 
    1912131; 
    192214 
Note: See TracChangeset for help on using the changeset viewer.