|
| |
|
|
Renegade
Posts: 94 Joined: 12/16/2003 Status: offline
|
Spooky login Problems - 5/20/2004 12:56:24
I have manage to get my page to redirect unless the user has enter pass and user but when i go back to the homepage then try and go back to the secure page it does not open unless i type in the pass and user again here is my asp code base around spooky login quote:
<%@ Language="VBSCRIPT"%> <%Option Explicit%> <!-- #include file="db_conn.asp" --> <!-- #include file="includes/emailcomponent.asp" --> <% Response.buffer=True If Session("UserName") = "" Then Response.redirect "/login.asp?Redirect=" &Request.Servervariables("URL") End if %> <% ' --------------------------- ' Login Database by Spooky © ' 1.11 ' --------------------------- Response.Buffer = True Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "Cache-Control", "must-revalidate" Response.AddHeader "Cache-Control", "no-cache" '------------------------------------------- ' Dim Variables '------------------------------------------- DIM T1, T2, C1, C2, C3, UID, cUsrName, cPassWrd, DataError, Auto_Login DIM bNameError, bPassError, bMailError, bLoginError, bEmailDecline, objRS, rsID, rsFirstName DIM DoForm, strTo, strBody, Redirect, strLoginURL, sSQL DIM bEntPassDecline, bPassDecline, bUsrDecline, bEntUsrDecline DIM rsEmail, rsPassword, rsActiveAccount, bConfirm, bCookie, bMail, errLogin '------------------------------------------- ' Only change this setup data! '------------------------------------------- CONST TEST_MODE = False CONST USE_COOKIE = True CONST CLEAR_COOKIE = True CONST AUTHENTICATE = True CONST COOKIE_NAME = "Talent" CONST NT_AUTH = False CONST SEND_MAIL = False CONST EMAILCOMPONENT = "CDONTS" CONST strServer = "" ' Email server CONST strFrom = "" ' From address CONST strSubject = "" ' Email subject line Auto_Login = False '------------------------------------------- ' Change no more! Unless you want to! :) '------------------------------------------- '------------------------------------------- ' Set variables '------------------------------------------- bCookie = False bMail = False bNameError = False bPassError = False bMailError = False DoForm = Request.Form("DoForm") ' Submit button was pressed cUsrName = Request.Cookies(COOKIE_NAME)("UserName") cPassWrd = Request.Cookies(COOKIE_NAME)("xPass") Redirect = Request("Redirect") ' Used where a forced login gets redirected to the originating page UID = Trim(Request("UID")) ' UID - Required for email authentication If Redirect <> "" then errLogin = "You must login first" If (cUsrName = "" AND NOT NT_AUTH) OR (Session("LoginAttempt") = "1") OR Request.Querystring("CMD").Count then Auto_Login = False Session("UserName") = "" Session("Admin") = "" Session("AccessLevel") = "" Session("LoginAttempt") = "" 'Session("FirstName") = "" 'Session("LastName") = "" If DoForm OR Auto_Login OR NT_AUTH then '------------------------------------------- ' Page function - Login '------------------------------------------- T1 = Trim(Replace(Request.Form("T1"),"'","''")) ' Login T2 = Trim(Replace(Request.Form("T2"),"'","''")) ' Password C1 = Request.Form("C1") ' Remember login If Auto_Login AND T1 = "" then T1 = cUsrName T2 = cPassWrd Session("LoginAttempt") = "1" End if If NT_AUTH then T1 = Request.ServerVariables("LOGON_USER") If C1 then bCookie = True If (C3 AND SEND_MAIL) then bMail = True If (T1="") then bNameError = True If (T2="" AND NOT NT_AUTH) then bPassError = True If (bNameError AND bMail) then bMailError = True '------------------------------------------- ' Set SQL String '------------------------------------------- If NOT bNameError AND NOT bPassError then sSQL = "SELECT * FROM Users WHERE UserName='" &lCase(T1)& "'" If NOT NT_AUTH then sSQL = sSQL&" AND Password='"&lCase(T2)&"'" bLoginError = False ElseIf bMail AND NOT bMailError then sSQL = "SELECT * FROM Users WHERE (UserName='" &lCase(T1)& "')" bLoginError = True End if If sSQL <> "" then '------------------------------------------- ' Check Database for matches '------------------------------------------- Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open sSQL, sDSN, 1, 2 If objRS.EOF OR objRS.BOF Then errLogin = "Your details were not found" bConfirm = False Else rsID = objRs.fields.item("ID").Value rsFirstName = objRs.fields.item("FirstName").Value rsEmail = objRs.fields.item("Email").Value rsPassword = objRs.fields.item("Password").Value rsActiveAccount = objRs.fields.item("ActiveAccount").Value objRs.fields.item("LoginCount").Value = objRs.fields.item("LoginCount").Value + "1" objRS.Update objRS.Close Set objRS = Nothing If rsActiveAccount OR (NOT AUTHENTICATE AND rsActiveAccount) then bConfirm = True '------------------------------------------- ' Send Password via Email '------------------------------------------- If SEND_MAIL AND NOT bMailError AND bLoginError then If test(rsEmail) then strLoginURL = "http://" & Request.Servervariables("HTTP_HOST") & Request.Servervariables("URL") strTo = rsEmail strBody = "Your password is "&rsPassword&vbCrLf&"You can login here "& strLoginURL EmailRecipient Redirect = "success.asp?CMD=Mail" bEmailDecline = False Else Redirect = "success.asp?CMD=NoMail" bEmailDecline = True End if Else If Trim(Redirect) = "" then Redirect = "my_talent.asp?CMD=Login" Session("UserName") = T1 ' Set session variable for later use End if '------------------------------------------- ' Set Cookie '------------------------------------------- If C1 and (NOT bMail OR NOT bMailError) AND NOT C2 then Response.Cookies(COOKIE_NAME).expires = #1/1/2010# Response.Cookies(COOKIE_NAME)("UserName") = T1 Response.Cookies(COOKIE_NAME)("xPass") = T2 End if If NOT TEST_MODE then Response.Clear Response.Redirect Redirect End if Else If Trim(UID) = Trim(rsID) then '------------------------------------------- ' Authenticate user '------------------------------------------- Set objRSInsert = Server.CreateObject("ADODB.RecordSet") objRSInsert.Open "SELECT * FROM Users WHERE ID=" &rsID, sDSN, 1, 2 objRSInsert.Fields.item(11).Value = True objRSInsert.Update objRSInsert.Close Set objRSInsert = Nothing bConfirm = True Redirect = "my_talent.asp?CMD=Auth" Session("UserName") = T1 '------------------------------------------- ' Cant Authenticate user, RS/UID not matched '------------------------------------------- bConfirm = False If AUTHENTICATE then errLogin = "I'm sorry but you need to be authenticated first." If Not AUTHENTICATE then errLogin = "I'm sorry but you are not listed as an Active member" End if End if End If End If End If If Request.Querystring("CMD") = "Clear" then Response.Cookies(COOKIE_NAME)="" Response.Cookies(COOKIE_NAME).expires = #1/10/2005# Else If USE_COOKIE AND T1 = "" then T1 = cUsrName If USE_COOKIE AND T2 = "" then T2 = cPassWrd End If '------------------------------------------- '------------------------------------------- %> why is this can anyone see what i can't Thanks Renengade
_____________________________
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|