Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default cflogin confusion

    Hi I need some help. Ifind lots of tutorials for simple login and for using
    cflogin in the Application...BUT nothing about using cf_login for single pages.
    Here are the codes I am using and ALL that is happening is I am returned to the
    login page everytime, if I enter correct or false data and NO error
    message...PLUS there is no login happening. !. I put this code in the BODY ON
    THE PAGE I want to secure: (The login form does show up on the page just does
    nothing) <body> <cfif not len(getAuthUser())> <cfset request.loginmessage =
    'You need to Log In.'> <cfinclude template='../LogIn/ForceUserLogIn.cfm'>
    </cfif> <!-- Get authorized user suppled in Name of login tag --> <cfset
    ContactName = ListFirst(GetAuthUser())> <cfoutput> <h2>Add or Edit a
    Event</h2> WELCOME BACK, #ContactName# </cfoutput> </body> I then have a login
    form; <!--- If the user is now submitting the 'login' form, include 'Login
    Check' code ---> <!--- to validate user ---> <cfif IsDefined('Form.UserLogin')>
    <cfinclude template='LoginCheck.cfm'> </cfif> <html> <head> <title>Log
    In</title> <meta http-equiv='Content-Type' content='text/html;
    charset=iso-8859-1'> </head> <body> <!--- Start our Log in Form ---> <cfform
    action='#CGI.SCRIPT_NAME#' name='LoginForm' method='post'> <!--- Make the
    UserLogIn and UserPass fields required ---> <input type='hidden'
    name='UserLogIn_required'> <input type='hidden' name='UserPass_required'>
    <table border='0' bgcolor='#FFFF00' align='right'> <tr><Th colspan='2'>Please
    Log in</Th></tr> <tr></tr> <tr></tr> <tr> <th>User Name (Alias): </th> <td>
    <!--- text field for user name 'Alias' ---> <cfinput type='text'
    name='UserLogIn' size='20' value='' maxlength='100' required='yes'
    message='Please type your user name AKA Your User Alias'> </td> </tr> <tr></tr>
    <tr></tr> <tr></tr> <tr> <th>Password: </th> <td> <!--- text field for
    Password ---> <cfinput type='password' name='UserPass' size='20' value=''
    maxlength='100' required='yes' message='Please insert your user password.'>
    <!--- Submit button that reads submit ---> <input type='submit' value='Log In'>
    </td> <td> </td> </tr> </table> <table> <tr> <td> </td> <td><font size='+1'
    face='Comic Sans MS, MS Serif, Arial'> Forgot your password? </font> <font
    face='Comic Sans MS, MS Serif, Arial'> Send it to your registered Email address
    </font> </td> <td> </td> <td> <a name='' onClick='window.open('./to
    email.cfm')'> <img src='../Images/fastemail.gif'> </td> </tr> </table>
    </cfform> <cfinclude template='../head and foot/footer.cfm'> </table>
    <cfinclude template='LogInFocus.cfm'> </body> </html> I then have a check if
    they are logged in form; <!--- validates a user login name and password --->
    <!--- first make sure we have a login name and password ---> <cfparam
    name='Form.UserLogIn' type='string'> <cfparam name='Form.UserPass'
    type='string'> <!--- find record with this user name and password ---> <!--- if
    no rows returned one or both are not valid ---> <cfquery name='GetUser'
    datasource='#REQUEST.DataSource#'> SELECT UserID, UserLogIn, UserCity,
    UserState, UserCounty, UserCountry FROM Users WHERE UserLogIn
    ='#Form.UserLogIn#' AND UserPass ='#Form.UserPass#' </cfquery> <!--- If the
    username and password are correct ---> <cfif GetUser.RecordCount EQ 1> <!---
    remember user's logged in status, plus ---> <!--- UserID and UserLogin name in
    structure ---> <cfset SESSION.Auth = StructNew()> <cfset
    SESSION.Auth.IsLoggedIn = 'yes'> <cfset SESSION.Auth.UserID = GetUser.UserID>
    <cfset SESSION.Auth.UserLogIn = GetUser.UserLogIn> <!--- Now that user is
    logged in, send them to whatever page they were trying to access --->
    <cflocation url='#CGI.SCRIPT_NAME#'> </cfif> Nothing seems to be working
    please help. I do not want a site that people have to log in to see anything as
    with application. I only want to secure the areas where the user can add or
    update their own info and for the site admin. Thank you John:confused;

    nckgb Guest

  2. Similar Questions and Discussions

    1. cflogin
      Hi, I'm using cflogin to build a simple application. If a user forgets their password, then they get asked a security question and if they answer...
    2. Using <cflogin>
      Is there a way to use CFLOGIN without requiring cookies? If so, how?
    3. cflogin problem
      I am using coldfusion authentication architecture to get the users logged in to my system. Authentication is working ok but it is giving me...
    4. Doesn't ANYBODY know anything about cflogin???
      :Q Do the people on this forum not know anything about cflogin OR is it they do not wish to share??? I posted a ? a week ago and I am still waiting...
    5. cflogin HELP
      Hi I need some help. Ifind lots of tutorials for simple login and for using cflogin in the Application...BUT nothing about using cf_login for single...
  3. #2

    Default Re: cflogin confusion

    nckgb wrote:
    > Hi I need some help. Ifind lots of tutorials for simple login and for using
    > cflogin in the Application...BUT nothing about using cf_login for single pages.
    > Here are the codes I am using and ALL that is happening is I am returned to the
    > login page everytime, if I enter correct or false data and NO error
    > message...PLUS there is no login happening. !. I put this code in the BODY ON
    > THE PAGE I want to secure:
    Unless I'm just missing it I don't see that you're using cflogin or
    cfloginuser anywhere on this page, so getAuthUser() is never going to
    return anything. Think of cflogin this way. Anything you put between
    your cflogin tags is only going to get executed if someone is not logged
    in, so for example you could put your login form in your cflogin tags.
    Also in my experience you have to have your cfloginuser tag inside a
    cflogin tag for it to work properly, so you'd have to do a check for the
    form submission, validate the user, and if that's successful then log
    the user in. There is a very basic example here that illustrates this:
    [url]http://tinyurl.com/5lqy6[/url]

    Whether you want to apply this to your entire site or one page, the
    principle would be the same.

    Hope that helps!
    Matt

    --
    Matt Woodward
    Team Macromedia - ColdFusion
    mpwoodward *TMM* Guest

  4. #3

    Default Re: cflogin confusion

    HIi Matt I did forget to put in the code I am using for ForceUserLog.cfm in my
    ? It is here <body> <cfif not len(getAuthUser())> <cfset request.loginmessage
    = 'You need to Log In.'> <cfinclude template='../LogIn/ForceUserLogIn.cfm'>
    <<<<<<!--- HERE --->>>>>> </cfif> And here is that pages code.
    <!--- Force the user to log in ---> <!--- This code executes only if the user
    has not logged in ---> <!--- Once the user is logged in via <cfloginuser>, this
    code will be skipped ---> <cflogin> <!--- If the user hasn't gotten the login
    form yet, display it ---> <cfif NOT (IsDefined('FORM.UserLogin') AND
    IsDefined('FORM.UserPassword'))> <cfinclude template='LoginForm.cfm'>
    <cfabort> <!--- Otherwise, the user is submitting the login form --->
    <!--- This code decides wheather the username and password are valid --->
    <cfelse> <!--- Find record with this Username/Password ---> <!--- If
    no rows returned, password not valid ---> <cfquery name='Logged'
    datasource='#REQUEST.DataSource#'> SELECT UserID, UserLogIn, UserPass,
    UserRoleName FROM Users WHERE UserLogIn = '#FORM.UserLogIn#' AND
    UserPass = '#Form.UserPass#' </cfquery> <!--- If the user name and password
    are correct ... ---> <cfif Logged.RecordCount EQ 1> <!--- Tell CF to
    consider the user logged in ---> <!--- For the name attribute, we will provide
    the user alias(UserLogin), seperated by commas. Later we can access the NAME
    value via GetAuthUser() ---> <cfloginuser
    NAME='#Logged.UserID#,#Logged.UserLogIn#' PASSWORD='#FORM.UserPass#'
    roles='#Logged.UserRoleName#'> <!--- Otherwise, re-prompt for a valid username
    and password ---> <cfelse> Sorry, we do not know this User Name OR Password.
    Please try again. <cfinclude template='LogInForm.cfm'> <<<<< <!--- HERE
    -->>>>>>< <cfabort> </cfif> </cfif> </cflogin> The cfform code is in the
    Log in form itself. that is include in the ForceUserLogin.cfm Thanks for any
    more help, soory I missed the other code. After hours of flustration, you start
    to lose it.

    nckgb Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139