X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FAuth%2Finternal.pm;h=5d9170e238aacbb66645e252e820f25158d18e2d;hp=86fddd237993a7f04ee2e379437d6507b20a7562;hb=199450cf528a5ac6b4fe739c38f9adf99a913712;hpb=92a3df0360d3df6b6ace99fee3d4cc443e6154d0 diff --git a/FS/FS/Auth/internal.pm b/FS/FS/Auth/internal.pm index 86fddd237..5d9170e23 100644 --- a/FS/FS/Auth/internal.pm +++ b/FS/FS/Auth/internal.pm @@ -2,14 +2,44 @@ package FS::Auth::internal; #use base qw( FS::Auth ); use strict; +use Crypt::Eksblowfish::Bcrypt qw(bcrypt_hash); +use FS::Record qw( qsearchs ); +use FS::access_user; sub authenticate { - my( $username, $check_password ) = @_; + my($self, $username, $check_password ) = @_; + my $access_user = qsearchs('access_user', { 'username' => $username, + 'disabled' => '', + } + ) + or return 0; -} + if ( $access_user->_password_encoding eq 'bcrypt' ) { + + my( $cost, $salt, $hash ) = split(',', $access_user->_password); + + my $check_hash = bcrypt_hash( { key_nul => 1, + cost => $cost, + salt => $salt, + }, + $check_password + ); + + $hash eq $check_hash; + + } else { + + return 0 if $access_user->_password eq 'notyet' + || $access_user->_password eq ''; + + $access_user->_password eq $check_password; + + } -sub change_password { } +#sub change_password { +#} + 1;