[LON-CAPA-cvs] cvs: loncom /auth lonauth.pm

raeburn raeburn at source.lon-capa.org
Wed Nov 24 15:15:15 EST 2021


raeburn		Wed Nov 24 20:15:15 2021 EDT

  Modified files:              
    /loncom/auth	lonauth.pm 
  Log:
  - Bug 6754
    - When log-in fails for a user with authentication set to lti: let user
      know they should launch LON-CAPA session via a different CMS.
  
  
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.170 loncom/auth/lonauth.pm:1.171
--- loncom/auth/lonauth.pm:1.170	Wed Nov 17 00:44:47 2021
+++ loncom/auth/lonauth.pm	Wed Nov 24 20:15:15 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.170 2021/11/17 00:44:47 raeburn Exp $
+# $Id: lonauth.pm,v 1.171 2021/11/24 20:15:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -300,7 +300,7 @@
 # --------------------------------------------------------------- Failed login!
 
 sub failed {
-    my ($r,$message,$form) = @_;
+    my ($r,$message,$form,$authhost) = @_;
     (undef,undef,undef,my $clientmathml,my $clientunicode) =
         &Apache::loncommon::decode_user_agent();
     my $args = {};
@@ -308,14 +308,19 @@
         $args = {'browser.unicode' => 1};
     }
 
+    my @actions;
     my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef,$args);
     my $uname = &Apache::loncommon::cleanup_html($form->{'uname'});
     my $udom = &Apache::loncommon::cleanup_html($form->{'udom'});
     if (&Apache::lonnet::domain($udom,'description') eq '') {
         undef($udom);
     }
+    my $authtype;
+    if (($udom ne '') && ($uname ne '') && ($authhost eq 'no_host')) {
+        $authtype = &Apache::lonnet::queryauthenticate($uname,$udom);
+    }
     my $retry = '/adm/login';
-    if ($uname eq $form->{'uname'}) {
+    if (($uname eq $form->{'uname'}) && ($authtype !~ /^lti:/)) {
         $retry .= '?username='.$uname;
     }
     if ($udom) {
@@ -363,18 +368,28 @@
     my $end_page = &Apache::loncommon::end_page();
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
-    my @actions =
-         (&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));
+    if ($authtype =~ /^lti:/) {
+        $message = &mt('Direct login is not supported with the username you entered.').
+                   '<br /><br />'.
+                   &mt('You likely need to launch LON-CAPA from within a course in a different Learning Management System.').
+                   '<br />'.
+                   &mt('You can also try to log in with a different username.');
+        @actions = 
+            (&mt('Try your [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));
+    } else {
+        $message = &mt($message);
+        @actions =
+            (&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>'));
+    }
     my $loginhelp = &loginhelpdisplay($udom);
     if ($loginhelp) {
         push(@actions, '<a href="'.$loginhelp.'">'.&mt('Login problems?').'</a>');
     }
     #FIXME: link to helpdesk might be added here
-
     $r->print(
        $start_page
       .'<h2>'.&mt('Sorry ...').'</h2>'
-      .&Apache::lonhtmlcommon::confirm_success(&mt($message),1).'<br /><br />'
+      .&Apache::lonhtmlcommon::confirm_success($message,1).'<br /><br />'
       .&Apache::lonhtmlcommon::actionbox(\@actions)
       .$end_page
     );
@@ -569,7 +584,7 @@
 
     if ($authhost eq 'no_host') {
 	&failed($r,'Username and/or password could not be authenticated.',
-		\%form);
+		\%form,$authhost);
         return OK;
     } elsif ($authhost eq 'no_account_on_host') {
         if ($defaultauth) {




More information about the LON-CAPA-cvs mailing list