Ver Mensaje Individual
  #15 (permalink)  
Antiguo 22/08/2005, 02:18
Avatar de Nombela
Nombela
 
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 11 meses
Puntos: 1
y esto forma parte del archivo donde se loga uno:

if ($Param{Action} eq "Login") {
# get params
my $PostUser = $CommonObject{ParamObject}->GetParam(Param => 'User') || '';
my $PostPw = $CommonObject{ParamObject}->GetParam(Param => 'Password') || '';
# create AuthObject
my $AuthObject = Kernel::System::CustomerAuth->new(%CommonObject);
# check submited data
my $User = $AuthObject->Auth(User => $PostUser, Pw => $PostPw);
if ($User) {
# get user data
my %UserData = $CommonObject{UserObject}->CustomerUserDataGet(User => $User, Valid => 1);
# check needed data
if (!$UserData{UserID} || !$UserData{UserLogin}) {
if ($CommonObject{ConfigObject}->Get('CustomerPanelLoginURL')) {
# redirect to alternate login
print $CommonObject{LayoutObject}->Redirect(
ExtURL => $CommonObject{ConfigObject}->Get('CustomerPanelLoginURL')."?Reason=SystemError ",
);
}
else {
# show login screen
print $CommonObject{LayoutObject}->CustomerLogin(
Title => 'Panic!',
Message => 'Panic! No UserData!!!',
%Param,
);
exit (0);
}
}
# last login preferences update
$CommonObject{UserObject}->SetPreferences(
UserID => $UserData{UserID},
Key => 'UserLastLogin',
Value => $CommonObject{TimeObject}->SystemTime(),
);
# create new session id
my $NewSessionID = $CommonObject{SessionObject}->CreateSessionID(
%UserData,
UserLastRequest => $CommonObject{TimeObject}->SystemTime(),
UserType => 'Customer',
);
# create a new LayoutObject with SessionIDCookie
my $Expires = '+'.$CommonObject{ConfigObject}->Get('SessionMaxTime').'s';
if (!$CommonObject{ConfigObject}->Get('SessionUseCookieAfterBrowserClose')) {
$Expires = '';
}
my $LayoutObject = Kernel::Output::HTML::Generic->new(
SetCookies => {
SessionIDCookie => $CommonObject{ParamObject}->SetCookie(
Key => $Param{SessionName},
Value => $NewSessionID,
Expires => $Expires,
),
},
SessionID => $NewSessionID,
SessionName => $Param{SessionName},
%CommonObject,
);

# --
# redirect with new session id and old params
# --
# prepare old redirect URL -- do not redirect to Login or Logout (loop)!
if ($Param{RequestedURL} =~ /Action=(Logout|Login)/) {
$Param{RequestedURL} = '';
}
# redirect with new session id
print $LayoutObject->Redirect(OP => "$Param{RequestedURL}");
}
# --
# login is vailid
# --
else {
if ($CommonObject{ConfigObject}->Get('CustomerPanelLoginURL')) {
# redirect to alternate login
$Param{RequestedURL} = $CommonObject{LayoutObject}->LinkEncode($Param{RequestedURL});
print $CommonObject{LayoutObject}->Redirect(
ExtURL => $CommonObject{ConfigObject}->Get('CustomerPanelLoginURL').
"?Reason=LoginFailed&RequestedURL=$Param{Requested URL}",
);
}
else {
# show normal login
print $CommonObject{LayoutObject}->CustomerLogin(
Title => 'Login',
Message => $CommonObject{LogObject}->GetLogEntry(
Type => 'Info',
What => 'Message',
) || 'Login failed! Your username or password was entered incorrectly.',
User => $User,
%Param,
);
}
}
__________________
:si: El hombre es el único animal que come sin tener hambre, bebe sin tener sed y habla sin tener nada que decir. :si: