EasyCFM.COM ColdFusion Forums / Coding Help! / "You must login to view this page"

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: "You must login to view this page"

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

charmed0rz
06-23-2004 @ 5:42 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 272
Joined: Jun 2004

It seems like all my .cfm pages arent able to be viewed not unless they login...  but how are they supposed to login if they cant get to the sign up page?? :P I assumed it was my application.cfm page:

<style type="text/css">
<!--
a{text-decoration:none}
a:link{text-decoration:none}
a:visited{text-decoration:none}
a:hover{text-decoration:none}
a:active{text-decoration:none}
-->
</style>


<!--- Now if the variable "session.allowin" does not equal true, send user to the login page --->
<!---
        the other thing you must check for is if the page calling this application.cfm is the "login.cfm" page
        and the "Login_process.cfm" page since the Application.cfm is always called, if this is not checked
        the application will simply Loop over and over. To check that, you do the following call

--->
<cfif session.allowin neq "true">
      <cfif ListLast(CGI.SCRIPT_NAME, "/") EQ "login.cfm">
      <cfelseif ListLast(CGI.SCRIPT_NAME, "/") EQ "login_process.cfm">
      <cfelse>
      <!--- this user is not logged in, alert user and redirect to the login.cfm page --->
      <script>
              alert("You must login to access this area!");
              self.location="login.cfm";
      </script>
      </cfif>
</cfif>
<cflock timeout="15" scope="APPLICATION" type="EXCLUSIVE">
    <cfif NOT isDefined("Application.UsersInfo")>
          <cfset Application.UsersInfo = StructNew()>
    </cfif>
</cflock>
<cflock name="#CreateUUID()#" timeout="15" type="EXCLUSIVE">
      <cfset user_cfid = Evaluate(CFID)>
      <cfset user_time = Now()>
</cflock>
<cflock scope="APPLICATION" type="EXCLUSIVE" timeout="15">
<cfif NOT StructKeyExists(Application.UsersInfo, user_cfid)>
  <cfset temp = StructInsert(Application.UsersInfo, user_cfid, user_time)>
</cfif>
</cflock>
<cflock scope="APPLICATION" type="EXCLUSIVE" timeout="15">
<cfloop collection="#Application.UsersInfo#" item="itmUser">
  <cfif
   Evaluate(DateDiff("n", StructFind(Application.UsersInfo, itmUser), Now())) GT 10
  >
    <cfset StructDelete(Application.UsersInfo, itmUser)>
  </cfif>
</cfloop>
</cflock>


Here is my signup page just in case
<font size="2">
For registration purposes we only require you give us the name
of your account, and password. You can change your gender, race,
and give your real name and other information in City Hall later.
You also need to read and agree with the terms of service below
before you register.

<form action="insert.cfm" method="post">
Character Name<input type="text" name="user_name"><br>
Password<input type="password" name="user_pass"><br>
<input type="submit" value="submit">
</form>

and my insert page: any help?? :S
<CFINSERT datasource="userlogin" tablename="tbladmins">
<font size="2">
Thank you. <br>
<A href="login.cfm">Click here to Login Now!</A>

This message was edited by charmed0rz on 6-23-04 @ 5:42 PM

MikeBam
06-23-2004 @ 5:54 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 237
Joined: Jul 2003

You have to add the sign up page to the exceptions:

<cfif session.allowin neq "true">
      <cfif ListLast(CGI.SCRIPT_NAME, "/") EQ "login.cfm">
      <cfelseif ListLast(CGI.SCRIPT_NAME, "/") EQ "login_process.cfm">
      <cfelseif ListLast(CGI.SCRIPT_NAME, "/") EQ "sign_up_page.cfm">
      <cfelse>
      <!--- this user is not logged in, alert user and redirect to the login.cfm page --->
      <script>
              alert("You must login to access this area!");
              self.location="login.cfm";
      </script>
      </cfif>
</cfif>


Mike

charmed0rz
06-23-2004 @ 11:48 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 272
Joined: Jun 2004

That worked perfectly, thanks.


Website Designed and Developed by Pablo Varando.