Commit 90a21ff63e50d0a192c18007ab9d067a75d4fa9d

Authored by Michael Joseph
1 parent f8e4ea20

login works with db authentication

ldap auth and redirecting outstanding


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@52 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 42 additions and 18 deletions
login.php
1 <?php 1 <?php
2 2
  3 +/**
  4 + * login.php -- Login page
  5 + *
  6 + * This page handles logging a user into the dms.
  7 + * This page displays the login form, and performs the business logic login processing.
  8 + *
  9 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  10 + *
  11 + * @version $Id$
  12 + * @Copyright (c) 1999-2002 The Owl Project Team
  13 + * @author michael
  14 + * @package dms
  15 + */
3 // main library routines and defaults 16 // main library routines and defaults
4 -require_once("./config/owl.php"); 17 +require_once("./config/dmsDefaults.php");
5 require_once("./lib/owl.lib.php"); 18 require_once("./lib/owl.lib.php");
  19 +require_once("./lib/control.inc");
6 require_once("./config/html.php"); 20 require_once("./config/html.php");
7 -require_once("./lib/Authenticator.inc");  
8 -require_once("./lib/Session.php"); 21 +require_once("./lib/Session.inc");
  22 +
9 23
10 -// this page displays the login form  
11 -// and performs the business logic login code  
12 24
13 if ($loginAction == "loginForm") { 25 if ($loginAction == "loginForm") {
14 // TODO: build login form using PatternMainPage 26 // TODO: build login form using PatternMainPage
15 include("./lib/header.inc"); 27 include("./lib/header.inc");
16 print("<CENTER>"); 28 print("<CENTER>");
17 print("<IMG SRC='$default->owl_root_url/locale/$default->owl_lang/graphics/$default->logo'><BR>$lang_engine<BR>$lang_version: $default->version<BR><HR WIDTH=300>"); 29 print("<IMG SRC='$default->owl_root_url/locale/$default->owl_lang/graphics/$default->logo'><BR>$lang_engine<BR>$lang_version: $default->version<BR><HR WIDTH=300>");
18 - print "<FORM ACTION=\"control.php\" METHOD=\"POST\">"; 30 + print "<FORM ACTION=\"login.php\" METHOD=\"POST\">";
19 31
20 if (isset($fileid)) { 32 if (isset($fileid)) {
21 print "<INPUT TYPE=\"HIDDEN\" NAME=\"parent\" value=\"$parent\">"; 33 print "<INPUT TYPE=\"HIDDEN\" NAME=\"parent\" value=\"$parent\">";
22 print "<INPUT TYPE=\"HIDDEN\" NAME=\"fileid\" value=\"$fileid\">"; 34 print "<INPUT TYPE=\"HIDDEN\" NAME=\"fileid\" value=\"$fileid\">";
23 } 35 }
  36 + if (isset($loginFailureMessage)) {
  37 + print "$loginFailureMessage<br>";
  38 + }
24 39
25 print "<TABLE><TR><TD>$lang_username:</TD><TD><INPUT TYPE=\"TEXT\" NAME=\"fUserName\"><BR></TD></TR>"; 40 print "<TABLE><TR><TD>$lang_username:</TD><TD><INPUT TYPE=\"TEXT\" NAME=\"fUserName\"><BR></TD></TR>";
26 print "<TR><TD>$lang_password:</TD><TD><INPUT TYPE=\"PASSWORD\" NAME=\"fPassword\"><BR></TD></TR></TABLE>"; 41 print "<TR><TD>$lang_password:</TD><TD><INPUT TYPE=\"PASSWORD\" NAME=\"fPassword\"><BR></TD></TR></TABLE>";
  42 + print "<input type=\"hidden\" name=\"redirect\" value=\"<?php echo $redirect ?>\"/>";
27 print "<INPUT TYPE=\"hidden\" name=\"action\" value=\"login\">\n"; 43 print "<INPUT TYPE=\"hidden\" name=\"action\" value=\"login\">\n";
28 print "<INPUT TYPE=\"hidden\" name=\"loginAction\" value=\"login\">\n"; 44 print "<INPUT TYPE=\"hidden\" name=\"loginAction\" value=\"login\">\n";
29 print "<INPUT TYPE=\"SUBMIT\" Value=\"$lang_login\">\n"; 45 print "<INPUT TYPE=\"SUBMIT\" Value=\"$lang_login\">\n";
30 print "<BR><BR><HR WIDTH=300>"; 46 print "<BR><BR><HR WIDTH=300>";
31 - include("./lib/footer.inc"); 47 + //include("./lib/footer.inc");
32 48
33 } elseif ($loginAction == "login") { 49 } elseif ($loginAction == "login") {
34 -  
35 // check the requirements 50 // check the requirements
36 if (checkrequirements() == 1) { 51 if (checkrequirements() == 1) {
37 // TODO: appropriate error message 52 // TODO: appropriate error message
@@ -40,33 +55,42 @@ if ($loginAction == &quot;loginForm&quot;) { @@ -40,33 +55,42 @@ if ($loginAction == &quot;loginForm&quot;) {
40 // if requirements are met and we have a username and password to authenticate 55 // if requirements are met and we have a username and password to authenticate
41 if( isset($fUserName) && isset($fPassword) ) { 56 if( isset($fUserName) && isset($fPassword) ) {
42 // verifies the login and password of the user 57 // verifies the login and password of the user
43 - $userDetails = Authenticator::login($fUserName, $fUserName)  
44 - 58 + $dbAuth = new DBAuthenticator();
  59 + $userDetails = $dbAuth->login($fUserName, $fUserName);
45 switch ($userDetails["status"]) { 60 switch ($userDetails["status"]) {
46 // successfully authenticated 61 // successfully authenticated
47 case 1: 62 case 1:
  63 + // start the session
48 $sessionID = Session::create($userDetails["userID"]); 64 $sessionID = Session::create($userDetails["userID"]);
49 - // check query string and forward to requested page  
50 - $qString = $_SERVER["QUERY_STRING"];  
51 - // should be login.php?  
52 - // else forward to dashboard (config defined page/action) 65 + // check for a location to forward to
  66 + //echo "started session, with id=$sessionID<br>";
  67 + /*
  68 + if (isset($redirect) && strlen(trim($redirect))>0) {
  69 + echo "it is set to $redirect<br>";
  70 + $url = $redirect;
  71 + //redirect($redirect);
  72 + } else {*/
  73 + $url = "control.php?action=DASHBOARD";
  74 + //}
  75 + //echo "url set to $url<br>";
53 break; 76 break;
54 // login disabled 77 // login disabled
55 case 2: 78 case 2:
56 - redirect("control.php?action=loginForm&loginFailureMessage="); 79 + $url = "control.php?action=loginForm&loginFailureMessage=$lang_logindisabled";
57 break; 80 break;
58 // too many sessions 81 // too many sessions
59 case 3 : 82 case 3 :
60 - redirect("control.php?action=loginForm&loginFailureMessage="); 83 + $url = "control.php?action=loginForm&loginFailureMessage=$lang_toomanysessions";
61 break; 84 break;
62 default : 85 default :
63 - redirect("control.php?action=loginForm&loginFailureMessage="); 86 + $url = "control.php?action=loginForm&loginFailureMessage=$lang_err_general";
64 } 87 }
65 } else { 88 } else {
66 // didn't receive any login parameters, so redirect login form 89 // didn't receive any login parameters, so redirect login form
67 $url = "control.php?action=loginForm"; 90 $url = "control.php?action=loginForm";
68 - redirect($url);  
69 } 91 }
  92 + //echo "about to redirect to $url<br>";
  93 + redirect($url);
70 } 94 }
71 } 95 }
72 ?> 96 ?>