Solved

Merged Login Problem

Posted on 2009-05-14
8
357 Views
Last Modified: 2013-12-25
I'll give $20 to anyone who provides me an answer to this problem that fixes it.
Here is login.asp's login script part:
CODE
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("userName"))
If MM_valUsername <> "" Then
  MM_fldUserAuthorization=""
  MM_redirectLoginSuccess="../welcome2.asp"
  MM_redirectLoginFailed="login.asp?valid=1"
  MM_flag="ADODB.Recordset"
  set MM_rsUser = Server.CreateObject(MM_flag)
  MM_rsUser.ActiveConnection = MM_connTest_STRING
  MM_rsUser.Source = "SELECT users_email, users_password"
  If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  MM_rsUser.Source = MM_rsUser.Source & " FROM test.users WHERE users_email='" & Replace(MM_valUsername,"'","''") &"' AND users_password='" & Replace(Request.Form("password"),"'","''") & "'"
  MM_rsUser.CursorType = 0
  MM_rsUser.CursorLocation = 2
  MM_rsUser.LockType = 3
  MM_rsUser.Open
  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
    ' username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername
    If (MM_fldUserAuthorization <> "") Then
      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
    Else
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And false Then
      MM_redirectLoginSuccess = Request.QueryString("accessdenied")
    End If
    MM_rsUser.Close
    Response.Redirect(MM_redirectLoginSuccess)
  End If
  MM_rsUser.Close
  Response.Redirect(MM_redirectLoginFailed)
End If
%>
This file used to be located in two directories, each leading to a different page (dir1/welcome.asp, dir2/welcome.asp)
Each of these welcome.asp files had the follow code at the top to choose whether or not the user was granted access:

CODE
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="..quote/login2.asp"
MM_grantAccess=true
If Session("MM_Username") <> "" Then
  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>


Why would dir1/welcome.asp work after I login but not dir2/welcome.asp. But yet if I login using the dir2/login.asp old script it lets me in...
0
Comment
Question by:CSharpGuru
  • 3
  • 3
  • 2
8 Comments
 
LVL 10

Expert Comment

by:MaxOvrdrv2
Comment Utility
i don't get what you're trying to do here... you have to logins that go to the same page? why? just have one login, and on the older login page, redirect to the new one!
0
 

Author Comment

by:CSharpGuru
Comment Utility
Ok I should be more clear. The developers for some reason to my site, made two seperate login pages, tied to the same database. They both direct to 2 seperate pages. I just want to change it to one login, which in turn directs them to a new page that lets them go to either page logged in. Before the chain went like this:
home page->Option 1->Login->Option one welcome page
                  ->Option 2->Login->Option two welcome page
I want it to be this way:
home page->Login->Choose option page->option 1 or two welcome page

That way they don't have to login twice if they switch to the other page b/c once they leave the area it logs them out. Plus having two login pages is kind of redundant. I have all this in effect but for some reason the login scripts don't work for option two, it still acts like I'm not authenticated. I don't know why. But option 1 it does say I'm authenticated. I still have to use the second login page to authenticate myself for option 2. But...both login scripts are the same...so why would it matter.
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
Comment Utility
super easy, to prevent old users from accessing the old login via the old/soon to be useless login page, simply change the code in the one that you have chosen to remove with this:

response.redirect("newloginpage.asp")

then, in the new login page, simply keep it working the way it was, or make some modifications if needed for the new way... once they are logged in, direct them to a page that you will create, which offers them the 2 options, and when they click on the option, they are sent to the right place...

let me know if that works for you... simple is best, don't try to merge 2 login pages into one... delete one, and use only the other one... ;-)
0
 
LVL 30

Expert Comment

by:Wayne Barron
Comment Utility
The old Dreamweaver Login Script.
I hated that script so bad it was unreal.
It did a 1/2 A** job, but was not the best thing in the world.

If you decide that you want to go a different route and dump that script
Let me know, I have a cookie demo that will work great for authenticating your users.

Good Luck
Carrzkiss
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:CSharpGuru
Comment Utility
yes if you have another login script I'd be more then happy to take a look at it.
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 500 total points
Comment Utility
sorry that I am repling so late.

http://ee.cffcs.com/Q_24252782/login.asp
code
http://ee.cffcs.com/Q_24252782/Q_24252782.zip
Username = logincookie
password = 12345678

Let me know if you have any questions.
Carrzkiss
0
 

Author Closing Comment

by:CSharpGuru
Comment Utility
Sorry I didn't see this before, even though the problem changed slightly your other post already fixed both situations :) You're simply amazing.
0
 
LVL 30

Expert Comment

by:Wayne Barron
Comment Utility
you are welcome.
Keep on coding.
Have a good one.

Carrzkiss
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now