X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fsvc_acct.pm;h=991cedd21da025697bc2cf0a5a8875709a296bc1;hp=d84240f36588accf5ab537ac750ab2c20d57e62d;hb=72a65ceaa28155e8c1c3c1328dd76587b35e089a;hpb=d57a7d6d2e1bedca8a0df351a3054baa6e57ea4a diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index d84240f36..991cedd21 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -14,6 +14,7 @@ use vars qw( @ISA $DEBUG $me $conf @saltset @pw_set ); use Carp; use Fcntl qw(:flock); +use Crypt::PasswdMD5; use FS::UID qw( datasrc ); use FS::Conf; use FS::Record qw( qsearch qsearchs fields dbh dbdef ); @@ -1116,6 +1117,36 @@ sub clone_kludge_unsuspend { new FS::svc_acct \%hash; } +=item check_password + +Checks the supplied password against the (possibly encrypted) password in the +database. Returns true for a sucessful authentication, false for no match. + +Currently supported encryptions are: classic DES crypt() and MD5 + +=cut + +sub check_password { + my($self, $check_password) = @_; + #eventually should check a "password-encoding" field + if ( length($self->_password) < 13 ) { #plaintext + $check_password eq $self->_password; + } elsif ( length($self->_password) == 13 ) { #traditional DES crypt + crypt($check_password, $self->_password) eq $self->_password; + } elsif ( $self->_password =~ /^\$1\$/ ) { #MD5 crypt + unix_md5_crypt($check_password, $self->_password) eq $self->_password; + } elsif ( $self->_password =~ /^\$2a?\$/ ) { #Blowfish + warn "Can't check password: Blowfish encryption not yet supported, svcnum". + $self->svcnum. "\n"; + 0; + } else { + warn "Can't check password: Unrecognized encryption for svcnum ". + $self->svcnum. "\n"; + 0; + } + +} + =back =head1 SUBROUTINES