version 1.147, 2017/08/08 18:17:13
|
version 1.152, 2018/05/08 15:44:11
|
Line 36 use Apache::loncommon();
|
Line 36 use Apache::loncommon();
|
use Apache::lonnet;
|
use Apache::lonnet;
|
use Apache::lonmenu();
|
use Apache::lonmenu();
|
use Apache::createaccount;
|
use Apache::createaccount;
|
|
use Apache::ltiauth;
|
use Fcntl qw(:flock);
|
use Fcntl qw(:flock);
|
use Apache::lonlocal;
|
use Apache::lonlocal;
|
use Apache::File();
|
use Apache::File();
|
Line 45 use Digest::MD5;
|
Line 46 use Digest::MD5;
|
# ------------------------------------------------------------ Successful login
|
# ------------------------------------------------------------ Successful login
|
sub success {
|
sub success {
|
my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
|
my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
|
$form) = @_;
|
$form,$skipcritical) = @_;
|
|
|
# ------------------------------------------------------------ Get cookie ready
|
# ------------------------------------------------------------ Get cookie ready
|
my $cookie =
|
my $cookie =
|
Line 64 sub success {
|
Line 65 sub success {
|
|
|
# ------------------------------------------------- Check for critical messages
|
# ------------------------------------------------- Check for critical messages
|
|
|
my @what=&Apache::lonnet::dump('critical',$domain,$username);
|
unless ($skipcritical) {
|
if ($what[0]) {
|
my @what=&Apache::lonnet::dump('critical',$domain,$username);
|
if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
|
if ($what[0]) {
|
$lowerurl='/adm/email?critical=display';
|
if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
|
|
$lowerurl='/adm/email?critical=display';
|
|
}
|
}
|
}
|
}
|
}
|
|
|
Line 93 sub success {
|
Line 96 sub success {
|
}
|
}
|
# -------------------------------------------------------- Menu script and info
|
# -------------------------------------------------------- Menu script and info
|
my $destination = $lowerurl;
|
my $destination = $lowerurl;
|
|
if ($env{'request.lti.login'}) {
|
|
if (($env{'request.lti.reqcrs'}) && ($env{'request.lti.reqrole'} eq 'cc')) {
|
|
&Apache::loncommon::content_type($r,'text/html');
|
|
if ($securecookie) {
|
|
$r->headers_out->add('Set-cookie' => $securecookie);
|
|
}
|
|
if ($defaultcookie) {
|
|
$r->headers_out->add('Set-cookie' => $defaultcookie);
|
|
}
|
|
$r->send_http_header;
|
|
if (ref($form) eq 'HASH') {
|
|
$form->{'lti.reqcrs'} = $env{'request.lti.reqcrs'};
|
|
$form->{'lti.reqrole'} = $env{'request.lti.reqrole'};
|
|
$form->{'lti.sourcecrs'} = $env{'request.lti.sourcecrs'};
|
|
}
|
|
&Apache::ltiauth::lti_reqcrs($r,$domain,$form,$username,$domain);
|
|
return;
|
|
}
|
|
if ($env{'request.lti.selfenrollrole'}) {
|
|
if (&Apache::ltiauth::lti_enroll($username,$domain,
|
|
$env{'request.lti.selfenrollrole'}) eq 'ok') {
|
|
$form->{'role'} = $env{'request.lti.selfenrollrole'};
|
|
&Apache::lonnet::delenv('request.lti.selfenrollrole');
|
|
} else {
|
|
&Apache::ltiauth::invalid_request($r,24);
|
|
}
|
|
}
|
|
}
|
if (defined($form->{role})) {
|
if (defined($form->{role})) {
|
my $envkey = 'user.role.'.$form->{role};
|
my $envkey = 'user.role.'.$form->{role};
|
my $now=time;
|
my $now=time;
|
Line 135 sub success {
|
Line 165 sub success {
|
$destination .= 'source=login';
|
$destination .= 'source=login';
|
}
|
}
|
|
|
my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";');
|
my $windowname = 'loncapaclient';
|
|
if ($env{'request.lti.login'}) {
|
|
$windowname .= 'lti';
|
|
}
|
|
my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="'.$windowname.'";');
|
my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
|
my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
|
my $brcrum = [{'href' => '',
|
my $brcrum = [{'href' => '',
|
'text' => 'Successful Login'},];
|
'text' => 'Successful Login'},];
|
Line 161 sub success {
|
Line 195 sub success {
|
}
|
}
|
}
|
}
|
}
|
}
|
my $start_page=&Apache::loncommon::start_page('Successful Login',
|
|
$header,$args);
|
|
my $end_page =&Apache::loncommon::end_page();
|
|
|
|
my $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';
|
|
# ------------------------------------------------- Output for successful login
|
# ------------------------------------------------- Output for successful login
|
|
|
&Apache::loncommon::content_type($r,'text/html');
|
&Apache::loncommon::content_type($r,'text/html');
|
Line 177 sub success {
|
Line 207 sub success {
|
}
|
}
|
$r->send_http_header;
|
$r->send_http_header;
|
|
|
my %lt=&Apache::lonlocal::texthash(
|
my $start_page;
|
'wel' => 'Welcome',
|
if ($env{'request.lti.login'}) {
|
'pro' => 'Login problems?',
|
$args = {'only_body' => 1,};
|
);
|
$start_page=&Apache::loncommon::start_page('',$header,$args);
|
my $loginhelp = &loginhelpdisplay($domain);
|
} else {
|
if ($loginhelp) {
|
$start_page=&Apache::loncommon::start_page('Successful Login',
|
$loginhelp = '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
|
$header,$args);
|
}
|
}
|
|
my $end_page =&Apache::loncommon::end_page();
|
|
|
|
my $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';
|
|
|
my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
|
my $pagebody;
|
|
unless ($env{'request.lti.login'}) {
|
|
my %lt=&Apache::lonlocal::texthash(
|
|
'wel' => 'Welcome',
|
|
'pro' => 'Login problems?',
|
|
);
|
|
$pagebody = "<h1>$lt{'wel'}</h1>\n".
|
|
&mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
|
|
my $loginhelp = &loginhelpdisplay($domain);
|
|
if ($loginhelp) {
|
|
$pagebody .= '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
|
|
}
|
|
}
|
$r->print(<<ENDSUCCESS);
|
$r->print(<<ENDSUCCESS);
|
$start_page
|
$start_page
|
$windowinfo
|
$windowinfo
|
<h1>$lt{'wel'}</h1>
|
$pagebody
|
$welcome
|
|
$loginhelp
|
|
$continuelink
|
$continuelink
|
$end_page
|
$end_page
|
ENDSUCCESS
|
ENDSUCCESS
|
Line 407 sub handler {
|
Line 450 sub handler {
|
my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
|
my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
|
$form{'udom'},$defaultauth,
|
$form{'udom'},$defaultauth,
|
$clientcancheckhost);
|
$clientcancheckhost);
|
|
|
# --------------------------------------------------------------------- Failed?
|
# --------------------------------------------------------------------- Failed?
|
|
|
if ($authhost eq 'no_host') {
|
if ($authhost eq 'no_host') {
|
Line 489 sub handler {
|
Line 532 sub handler {
|
# (b) same primary library server for the two domains
|
# (b) same primary library server for the two domains
|
# (c) same "internet domain" for primary library server(s) for home servers' domains
|
# (c) same "internet domain" for primary library server(s) for home servers' domains
|
#
|
#
|
my $uprim = &Apache::lonnet::domain($sudom,'primary');
|
my $suprim = &Apache::lonnet::domain($sudom,'primary');
|
my $uintdom = &Apache::lonnet::internet_dom($uprim);
|
my $suintdom = &Apache::lonnet::internet_dom($suprim);
|
unless ($sudom eq $form{'udom'}) {
|
unless ($sudom eq $form{'udom'}) {
|
my $suprim = &Apache::lonnet::domain($sudom,'primary');
|
my $uprim = &Apache::lonnet::domain($form{'udom'},'primary');
|
my $suintdom = &Apache::lonnet::internet_dom($suprim);
|
my $uintdom = &Apache::lonnet::internet_dom($uprim);
|
unless ($suprim eq $uprim) {
|
unless ($suprim eq $uprim) {
|
unless ($suintdom eq $uintdom) {
|
unless ($suintdom eq $uintdom) {
|
&Apache::lonnet::logthis('Attempted switch user '
|
&Apache::lonnet::logthis('Attempted switch user '
|
Line 510 sub handler {
|
Line 553 sub handler {
|
#
|
#
|
my $lonhost = $r->dir_config('lonHostID');
|
my $lonhost = $r->dir_config('lonHostID');
|
my $hostintdom = &Apache::lonnet::internet_dom($lonhost);
|
my $hostintdom = &Apache::lonnet::internet_dom($lonhost);
|
if ($hostintdom ne $uintdom) {
|
if ($hostintdom ne $suintdom) {
|
&Apache::lonnet::logthis('Attempted switch user on a '
|
&Apache::lonnet::logthis('Attempted switch user on a '
|
.'server with a different "internet domain".');
|
.'server with a different "internet domain".');
|
} else {
|
} else {
|