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 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 16 // main library routines and defaults
4   -require_once("./config/owl.php");
  17 +require_once("./config/dmsDefaults.php");
5 18 require_once("./lib/owl.lib.php");
  19 +require_once("./lib/control.inc");
6 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 25 if ($loginAction == "loginForm") {
14 26 // TODO: build login form using PatternMainPage
15 27 include("./lib/header.inc");
16 28 print("<CENTER>");
17 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 32 if (isset($fileid)) {
21 33 print "<INPUT TYPE=\"HIDDEN\" NAME=\"parent\" value=\"$parent\">";
22 34 print "<INPUT TYPE=\"HIDDEN\" NAME=\"fileid\" value=\"$fileid\">";
23 35 }
  36 + if (isset($loginFailureMessage)) {
  37 + print "$loginFailureMessage<br>";
  38 + }
24 39  
25 40 print "<TABLE><TR><TD>$lang_username:</TD><TD><INPUT TYPE=\"TEXT\" NAME=\"fUserName\"><BR></TD></TR>";
26 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 43 print "<INPUT TYPE=\"hidden\" name=\"action\" value=\"login\">\n";
28 44 print "<INPUT TYPE=\"hidden\" name=\"loginAction\" value=\"login\">\n";
29 45 print "<INPUT TYPE=\"SUBMIT\" Value=\"$lang_login\">\n";
30 46 print "<BR><BR><HR WIDTH=300>";
31   - include("./lib/footer.inc");
  47 + //include("./lib/footer.inc");
32 48  
33 49 } elseif ($loginAction == "login") {
34   -
35 50 // check the requirements
36 51 if (checkrequirements() == 1) {
37 52 // TODO: appropriate error message
... ... @@ -40,33 +55,42 @@ if ($loginAction == &quot;loginForm&quot;) {
40 55 // if requirements are met and we have a username and password to authenticate
41 56 if( isset($fUserName) && isset($fPassword) ) {
42 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 60 switch ($userDetails["status"]) {
46 61 // successfully authenticated
47 62 case 1:
  63 + // start the session
48 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 76 break;
54 77 // login disabled
55 78 case 2:
56   - redirect("control.php?action=loginForm&loginFailureMessage=");
  79 + $url = "control.php?action=loginForm&loginFailureMessage=$lang_logindisabled";
57 80 break;
58 81 // too many sessions
59 82 case 3 :
60   - redirect("control.php?action=loginForm&loginFailureMessage=");
  83 + $url = "control.php?action=loginForm&loginFailureMessage=$lang_toomanysessions";
61 84 break;
62 85 default :
63   - redirect("control.php?action=loginForm&loginFailureMessage=");
  86 + $url = "control.php?action=loginForm&loginFailureMessage=$lang_err_general";
64 87 }
65 88 } else {
66 89 // didn't receive any login parameters, so redirect login form
67 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 ?>
... ...