Login.asp Code for the Retail Solution Site

Following is the code for the Login.asp for the Retail Solution Site. If you choose to use AuthFilter for the Retail site, you must use this code for your site Login.asp. For more information, see Enabling AuthFilter for the Retail Solution Site.

<!-- #INCLUDE FILE="../include/header.asp" -->
<!-- #INCLUDE FILE="../include/const.asp" -->
<!-- #INCLUDE FILE="../include/html_lib.asp" -->
<!-- #INCLUDE FILE="../include/form_lib.asp" -->
<!-- #INCLUDE FILE="../include/std_access_lib.asp" -->
<!-- #INCLUDE FILE="../include/std_profile_lib.asp" -->
<!-- #INCLUDE FILE="../include/std_cookie_lib.asp" -->
<!-- #INCLUDE FILE="../include/std_url_lib.asp" -->
<!-- #INCLUDE FILE="../include/std_util_lib.asp" -->
<!-- #INCLUDE FILE="../include/setupenv.asp" -->
<!-- #INCLUDE FILE="../template/no_menu.asp" -->

<%
REM sample file for using with AuthFilter
REM This file handles Login for user
%>

<%

   Sub Main()
   End Sub
   
   Dim strSelect, strUsername, strPassword, strPWD, retAsp
   dim objAuth
   Dim strAuthErr, strSiteName, sUserID
   
   set objAuth = Server.CreateObject("Commerce.AuthManager")
   strSiteName = CStr(Application("MSCSCommerceSiteName"))
   objAuth.Initialize(strSiteName)
   
   'Get the hidden variable to determine if this is the first run of the page
   strSelect = Request.Querystring("realSubmit")
   
   'If users pressed the submit button
   if strSelect = "fromButton" then
      'authenticate the user
      strUsername = Request.Querystring("txtUsername")
      strPassword = Request.Querystring("txtPassword")
      
         if (strUsername = "") or (strPassword = "") then
            Response.Redirect "Login.asp"
         end If
         
         Set mscsUserProfile = GetUserProfileByLoginName(strUsername)
         if (mscsUserProfile is nothing) then
            Response.Redirect "Login.asp"
         end if
         
         if (mscsUserProfile.Fields("GeneralInfo.user_security_password").Value = strPassword) then
            sUserID = mscsUserProfile.Fields(GetQualifiedName(GENERAL_INFO_GROUP, FIELD_USER_ID)).Value
            ' for Custom/NT Auth
            objAuth.SetAuthTicket sUserID, 1, 90 
         
            ' Go to the Original requested ASP which is stored in cookie MSCSFirstRequestedURL"
            retAsp = Request.Cookies("MSCSFirstRequestedURL")
            if (retAsp = "" Or IsNUll(retAsp)) then
            retAsp = objAuth.GetURL("default.asp", True, False)
            end if
            Response.Redirect retAsp
         else
            Response.Redirect "Login.asp"
         end if
   else
      PrintLogin
   End if
%>

<%Sub PrintLogin() %>
<HTML>
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<FORM NAME="frmLogin" ACTION="Login.asp" METHOD="GET">
<br>
<br>
<br>
<H2 ID=L_LoginForm_HTMLText>CS2K-LoginForm</H2><ID Id=L_EnterCredential_ErrorMessage>
To access authenticated content, please enter your UserID & Password</ID>
<br>
<br>
<br>

<H3 ID=L_UserName_HTMLText>Username:<INPUT TYPE="text" NAME="txtUsername" SIZE=32 MAXLENGTH=32><br><ID ID=L_UserPassword_HTMLText>
Password :</ID><INPUT TYPE="password" NAME="txtPassword" SIZE=32 MAXLENGTH=32></H3><br>
<br>

<INPUT type=HIDDEN name="realSubmit" value="fromButton">
<p align="left">
   <input type="submit" name="action" id=L_Submit_Button value="Submit">
   <input type="reset" name="action" id=L_Reset_Button value="Reset"> 
</p>
</FORM>

<H4>
<br>
<br>
<%
REM SOLUTION SITES: Retail
REM    need to add own registration file under '\AuthFiles\' sub-Dir Or Copy ..\Retail\login\newuser.asp to '\AuthFiles\newuser.asp'
REM    in global.asa update: dictPages.NewUser = "AuthFiles/newuser.asp"
REM
%>
<A HRef="newuser.asp" ID=L_RegisterIf_HTMLText>Register if you are a new user 
   (solution sites: need to add own registration file under '\AuthFiles\' sub-Dir Or Copy ..\Retail\login\newuser.asp & update NewUser-File in Global.asa)</A>
<br>
</H4>

</BODY>
</HTML>
<%end sub%>

See Also

Working with Site Security and Filters

Enabling AuthFilter for the Retail Solution Site


All rights reserved.