[Bps-public-commit] r16724 - RT-Authen-ExternalAuth/trunk/html/Callbacks/ExternalAuth/autohandler
zordrak at bestpractical.com
zordrak at bestpractical.com
Thu Nov 6 13:21:05 EST 2008
Author: zordrak
Date: Thu Nov 6 13:21:05 2008
New Revision: 16724
Modified:
RT-Authen-ExternalAuth/trunk/html/Callbacks/ExternalAuth/autohandler/Auth
Log:
RT::Authen::ExternalAuth
* Attempted fix for Auth and autocreate issues
Modified: RT-Authen-ExternalAuth/trunk/html/Callbacks/ExternalAuth/autohandler/Auth
==============================================================================
--- RT-Authen-ExternalAuth/trunk/html/Callbacks/ExternalAuth/autohandler/Auth (original)
+++ RT-Authen-ExternalAuth/trunk/html/Callbacks/ExternalAuth/autohandler/Auth Thu Nov 6 13:21:05 2008
@@ -32,12 +32,10 @@
# Unless we have loaded a valid user with a UserID
# check if user exists externally and autocreate if it does
unless ($session{'CurrentUser'}->Id) {
-
- $session{'CurrentUser'} = RT::User->new($RT::SystemUser);
- my ($val, $ret, $msg);
if(RT::Authen::ExternalAuth::UserExists($user)){
- ($val, $msg) =
- $session{'CurrentUser'}->Create(%{ref($RT::AutoCreate) ? $RT::AutoCreate : {}},
+ my $UserObj = RT::User->new($RT::SystemUser);
+ my ($val, $msg) =
+ $UserObj->Create(%{ref($RT::AutoCreate) ? $RT::AutoCreate : {}},
Name => $user,
Gecos => $user,
);
@@ -45,31 +43,38 @@
$RT::Logger->error( "Couldn't create user $user: $msg" );
return;
}
- $RT::Logger->info( "Autocreated authenticated user",
- $session{'CurrentUser'}->Name,
+ $RT::Logger->info( "Autocreated external user",
+ $UserObj->Name,
"(",
- $session{'CurrentUser'}->Id,
+ $UserObj->Id,
")");
-
- ($val, $msg) = $session{'CurrentUser'}->SetName($user);
- $RT::Logger->debug("Set Name result: Val:",$val,"Msg:",$msg);
+
+ $RT::Logger->debug("Loading new user (",
+ $user,
+ ") into current session");
+ $session{'CurrentUser'}->Load($user);
}
}
-
- # If a password was given on the login page, validate it
- if (defined($pass)) {
- $RT::Logger->debug("\$pass defined ($pass), Running IsPassword");
- $password_validated = $session{'CurrentUser'}->IsPassword($pass);
- }
-
- unless($password_validated) {
- $RT::Logger->debug("Password Incorrect");
- delete $session{'CurrentUser'};
- }
}
# If we now have a completely valid RT user to play with...
if ($session{'CurrentUser'} && $session{'CurrentUser'}->Id) {
+
+ # If a password was given on the login page, validate it
+ if (defined($pass)) {
+ $RT::Logger->debug("\$pass defined ($pass), Running IsPassword");
+ $password_validated = $session{'CurrentUser'}->UserObj->IsPassword($pass);
+ }
+
+ unless($password_validated) {
+ $RT::Logger->debug("Password Incorrect");
+ delete $session{'CurrentUser'};
+ }
+ }
+
+ # If we STILL have a completely valid RT user to play with...
+ # and therefore password has been validated...
+ if ($session{'CurrentUser'} && $session{'CurrentUser'}->Id) {
# Even if we have JUST created the user in RT, we are going to
# reload their information from an external source. This allows us
@@ -95,8 +100,9 @@
# done by the autohandler this Callback is extending if
# we delete the session.
- # If we have a full user and the session hasn't already been deleted
+ # If we **STILL** have a full user and the session hasn't already been deleted
if ($session{'CurrentUser'} && $session{'CurrentUser'}->Id) {
+ # Sanity check
if($password_validated) {
$RT::Logger->info( "Successful login for",
More information about the Bps-public-commit
mailing list