<!--- 
  Filename:     LoginCheck.cfm
  Created by:   Nate Weiss (NMW)
  Date Created: 2/18/2001
  Please Note:  Included by LoginForm.cfm
--->


<!--- Make sure we have Login name and Password --->
<CFPARAM NAME="Form.UserLogin" TYPE="string">
<CFPARAM NAME="Form.UserPassword" TYPE="string">

<!--- Find record with this Username/Password --->
<!--- If no rows returned, password not valid --->
<CFQUERY NAME="GetUser" DATASOURCE="#REQUEST.DataSource#">
  SELECT ContactID, FirstName
  FROM Contacts
  WHERE UserLogin    = '#Form.UserLogin#'
    AND UserPassword = '#Form.UserPassword#'
</CFQUERY>

<!--- If the username and password is correct --->
<CFIF GetUser.RecordCount EQ 1>
  <!--- Remember user's logged-in status, plus --->
  <!--- ContactID and First Name, in structure --->
  <CFSET SESSION.Auth = StructNew()>
  <CFSET SESSION.Auth.IsLoggedIn = "Yes">
  <CFSET SESSION.Auth.ContactID  = GetUser.ContactID>
  <CFSET SESSION.Auth.FirstName  = GetUser.FirstName>

  <!--- Now that user is logged in, send them --->
  <!--- to whatever page makes sense to start --->
  <CFLOCATION URL="#SCRIPT_NAME#?#CGI.QUERY_STRING#">
</CFIF>