X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FAuthCookieHandler.pm;h=b571e4705ca4a9100c6a73e728a30f73623d395f;hb=8861d46820af163c7de7839178b6120c9b32ab2c;hp=a8ee37079aa10fe3d73688c1b5c3128d34166fef;hpb=e62544064299324ab04abae64cc33afef12a24aa;p=freeside.git diff --git a/FS/FS/AuthCookieHandler.pm b/FS/FS/AuthCookieHandler.pm index a8ee37079..b571e4705 100644 --- a/FS/FS/AuthCookieHandler.pm +++ b/FS/FS/AuthCookieHandler.pm @@ -4,34 +4,28 @@ use base qw( Apache2::AuthCookie ); use strict; use FS::UID qw( adminsuidsetup preuser_setup ); use FS::CurrentUser; - -my $module = 'legacy'; #XXX i am set in a conf somehow? or a config file +use FS::Auth; sub authen_cred { my( $self, $r, $username, $password ) = @_; - unless ( _is_valid_user($username, $password) ) { + preuser_setup(); + + my $info = {}; + + unless ( FS::Auth->authenticate($username, $password, $info) ) { warn "failed auth $username from ". $r->connection->remote_ip. "\n"; return undef; } warn "authenticated $username from ". $r->connection->remote_ip. "\n"; - adminsuidsetup($username); - - FS::CurrentUser->new_session; -} - -sub _is_valid_user { - my( $username, $password ) = @_; - my $class = 'FS::Auth::'.$module; - - #earlier? - eval "use $class;"; - die $@ if $@; - - $class->authenticate($username, $password); + FS::CurrentUser->load_user( $username, + 'autocreate' => FS::Auth->auth_class->autocreate, + %$info, + ); + FS::CurrentUser->new_session; } sub authen_ses_key { @@ -47,7 +41,6 @@ sub authen_ses_key { } $curuser->username; - } 1;