blob: 5d9170e238aacbb66645e252e820f25158d18e2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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($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 {
#}
1;
|