Forums

ASP

This topic is locked

Login Issues

Posted 23 Jul 2001 13:01:32
1
has voted
23 Jul 2001 13:01:32 Joe Utichi posted:
Hi! I am trying to develop a way for my users to be directed to where they were when they log in. For example. If you are not logged in, and you click on a link, you are redirected to the login page. At the moment the login page is pointing to the index page, but I want to to go back to whatever link it was they were at when they were trying to log in. Here is what I have:

<%
If ForumRS5__strUserID <> "xyz" then
If Not ForumRS5.EOF Then
Session("svUserID" = (ForumRS5.Fields.Item("UserID".Value)
Session("svUsrPassword" = (ForumRS5.Fields.Item("UsrPassword".Value)
Session("svDesignation" = (ForumRS5.Fields.Item("Designation".Value)
Response.Redirect "forumlist.asp"
Else
Response.Redirect "notsigned.asp"
End If
End If
%>

I want to replace forumlist.asp with a command to take them back from whence they came. I know it is a server extension property in UD4, but for some reason that extension isn't working so I can't see the code... could someone try setting up a login page maybe and telling me what the code says? dunno if this would be the best way. thanks

Replies

Replied 23 Jul 2001 15:39:57
23 Jul 2001 15:39:57 Joel Martinez replied:
sure, you can make the login link look something like this:
<pre id=code><font face=courier size=2 id=code>&lt;a href="login.asp?redirect=&lt;%=request("url"%&gt;"&gt;Login&lt;/a&gt;</font id=code></pre id=code>

that will put the current URL that you're at in the querstring... then you can check for it in the login procedure:
<pre id=code><font face=courier size=2 id=code>if request("redirect" &lt;&gt; "" then
<b>response.redirect request("redirect"</b>
else
<b>Response.Redirect "forumlist.asp"</b>
end if</font id=code></pre id=code>

I'm sure you'll have to play with it to get the relative paths to work correctly, but it shouldn't be that much different that this.

Joel Martinez

----------
Is this thing on?....

Edited by - joelmartinez on 07/23/2001 15:40:49
Replied 24 Jul 2001 07:45:59
24 Jul 2001 07:45:59 Joe Utichi replied:
I'm not sure that will work, as the code on the newtopic and postreply page is set up to forward - not link, with some asp:

&lt;%
dim Designation
Designation = Session("svDesignation"

If Designation &lt;&gt; "Admin" And Designation &lt;&gt; "Member" And Designation &lt;&gt; "Moderator" Then
Response.Redirect "login.asp"
End If
%&gt;

I understand the second part, with no probs - but how can I implement "login.asp?redirect=&lt;%=request("url"%&gt;" into the above ASP code?

Replied 24 Jul 2001 14:41:44
24 Jul 2001 14:41:44 Joel Martinez replied:
<pre id=code><font face=courier size=2 id=code>&lt;%
dim Designation
Designation = Session("svDesignation"

If Designation &lt;&gt; "Admin" And Designation &lt;&gt; "Member" And Designation &lt;&gt; "Moderator" Then
Response.Redirect "login.asp<b>?redirect=" & request("url"</b>
End if
%&gt;
</font id=code></pre id=code>

Joel Martinez

----------
Is this thing on?....

Edited by - joelmartinez on 07/24/2001 14:42:21
Replied 24 Jul 2001 14:59:12
24 Jul 2001 14:59:12 Joe Utichi replied:
Hmm, still not having any luck. here is what I have:

login.asp:
&lt;%
If ForumRS5__strUserID &lt;&gt; "xyz" then
If Not ForumRS5.EOF Then
Session("svUserID" = (ForumRS5.Fields.Item("UserID".Value)
Session("svUsrPassword" = (ForumRS5.Fields.Item("UsrPassword".Value)
Session("svDesignation" = (ForumRS5.Fields.Item("Designation".Value)
if request("redirect" &lt;&gt; "" then
Response.Redirect request("redirect"
Else
Response.Redirect "notsigned.asp"
End If
End If
End If
%&gt;

newtopic.asp:

&lt;%dim Designation
Designation = Session("svDesignation"
If Designation &lt;&gt; "Admin" And Designation &lt;&gt; "Member" And Designation &lt;&gt; "Moderator" Then
Response.Redirect "login.asp?redirect=" & request("url"
End if%&gt;

At the moment, when I go to newtopic.asp, I am redirected to this URL:

localhost/vforum/login.asp?redirect=/vforum/newtopic.asp

which means it is pulling the url, but when I log in it goes to:

localhost/vforum/notsigned.asp

Which is the URL set as the wrong password URL. But I am sure the password is correct...

Replied 24 Jul 2001 15:03:29
24 Jul 2001 15:03:29 Joe Utichi replied:
Oh, also - when i try to go back and post a message, it allows me so it knows I am logged in. It is just the redirect on the login page which seems to be at error.

Replied 24 Jul 2001 15:08:27
24 Jul 2001 15:08:27 Joe Utichi replied:
And to add to that - when I log in with fake details, it refreshes login.asp and gets rid of the redirect info in the top window.

I tried switching the urls in log in, in case they were the wrong way round (which would explain why it was sending me to notsigned.asp for a correct login, but all that does is give me an error "URL required" on the redirect line when I try to log in.

Replied 24 Jul 2001 15:20:28
24 Jul 2001 15:20:28 Joel Martinez replied:
<pre id=code><font face=courier size=2 id=code>&lt;%
If ForumRS5__strUserID &lt;&gt; "xyz" then
If Not ForumRS5.EOF Then
Session("svUserID" = (ForumRS5.Fields.Item("UserID".Value)
Session("svUsrPassword" = (ForumRS5.Fields.Item("UsrPassword".Value)
Session("svDesignation" = (ForumRS5.Fields.Item("Designation".Value)
if request("redirect" &lt;&gt; "" then
Response.Redirect request("redirect"
Else
Response.Redirect <b>"index.asp"</b>
End If

<b>ELSE
Response.Redirect "notsigned.asp?redirect=" & request("redirect"</b>
End If
End If
%&gt;</font id=code></pre id=code>
you had the conditions set up wrong... it was sending you to notsigned.asp if the login was successful, I added an else clause to the <b>If Not ForumRS5.EOF Then</b> because if it <b>is</b> eof (which means they didn't log in) then you want them to redirect to the notsigned...

also, I appended the redirect URL to the notsigned.asp so that it can go along for the ride... just look at it this way, if you still need the redirect, just append it to any URL that you're going to forward to...

Joel Martinez

----------
Is this thing on?....
Replied 24 Jul 2001 15:42:07
24 Jul 2001 15:42:07 Joe Utichi replied:
Its doing what it should, but it isn't taking me back to where I was, it is now just going to index.asp. How can I change the location to reflect what is in the redirect?

For example, the redirect should be newreply.asp but when I go, you have written it to go to index.asp - I want it to go to newreply.asp (or, whatever the user has come from which could be newtopic.asp or replyquote.asp)

Replied 24 Jul 2001 16:39:16
24 Jul 2001 16:39:16 Joel Martinez replied:
<pre id=code><font face=courier size=2 id=code>if request("redirect" &lt;&gt; "" then
Response.Redirect request("redirect"
Else
Response.Redirect "index.asp"
End If</font id=code></pre id=code>

hmm... then I'm missing something... the if statement up there is supposed to check to see if there's anyting in the redirect querystring, if it's there, it'll redirect to that value, if not, it'll send you off to index.asp

if it's not finding request("redirect" then it must not be in the qerystring... try commenting out the redirects, and doing
response.write request("redirect"

this will let you see if it's actually getting a value... once you've established that I think that you need to take a step back, and rethink some of this.
I've been in your exact situation before,
-getting help from a messageboard.
-the Topic goes on for ages.

after a while, it all seems like gibberish, and you're not really getting anywhere.
I've found that in that situation, going back, and doing some pseudo-code really helps your brain process what the code is trying to do...

just write out what the code is trying to do in plain english, then start to add code to what you've written, then you can see if that lines up with what you currently have...

Joel Martinez

----------
Is this thing on?....
Replied 24 Jul 2001 16:48:28
24 Jul 2001 16:48:28 Joe Utichi replied:
ahh, I think I see whats happening. when go to the login page, it reads the redirect - but when I log in, and the page refreshes, the redirect disappears. I just can't see how to remedy it.

There is an option in UD4 to log in a user that has the "Go to previous URL" option. Perhaps if someone could set up a dummy page and use this behaviour I could take a look at that code? I would do it - but the reason for not using this method to start with is that my server behaviours that come with UD4 don't seem to work, at least not the user authentication ones... THink someone could do that for me?

Reply to this topic