user and admin login on same login page

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default user and admin login on same login page

    Hello,

    I have a user login page which also doubles as my administrator login.
    Currently, my method of logging in doesnt seem to be working because it directs
    me to the members page first, then i must click logout and do it again to be
    able to get to admin.cfm. What is the best way of doing this? Also, what
    kind of security concerns are there regarding using the same login page that I
    should be aware of? Any code changes that will protect me from unauthorized
    access?

    Thanks!!

    Mark



    <cfif IsDefined("FORM.id")>
    <cfset MM_redirectLoginSuccess="members.cfm">
    <cfset MM_redirectLoginFailed="login.cfm?loginfailed=1">
    <cfquery name="MM_rsUser" username="---------" password="--------"
    datasource="---------">
    SELECT * FROM users WHERE username='#FORM.id#' AND password='#FORM.pw#'
    </cfquery>
    <cfif MM_rsUser.RecordCount NEQ 0>
    <cftry>
    <cflock scope="Session" timeout="30" type="Exclusive">
    <cfset Session.MM_Permissions=#MM_rsUser.Permissions#>
    <cfset Session.MM_Username=FORM.id>
    <cfset Session.MM_UserAuthorization="">
    </cflock>


    <cfif Session.MM_Permissions NEQ "user">
    <cfset MM_redirectLoginSuccess="admin.cfm">
    </cfif>

    <cfif IsDefined("URL.accessdenied") AND true>
    <cfset MM_redirectLoginSuccess=URL.accessdenied>
    </cfif>
    <cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
    <cfcatch type="Lock">
    <!--- code for handling timeout of cflock --->
    </cfcatch>
    </cftry>
    </cfif>
    <cflocation url="#MM_redirectLoginFailed#" addtoken="no">
    <cfelse>
    <cfset MM_LoginAction=CGI.SCRIPT_NAME>
    <cfif CGI.QUERY_STRING NEQ "">
    <cfset MM_LoginAction=MM_LoginAction & "?" & CGI.QUERY_STRING>
    </cfif>
    </cfif>

    davellaman Guest

  2. Similar Questions and Discussions

    1. Strange problem with Forms authentication: After successfull login, login page is still displayed
      Hi there I have a quite strange problem with my ASP.NET-Application. The application has being deployed one year ago and worked fine till last...
    2. Can't Login to Admin Page
      I have recently re-installed CF to work with WAMP 5 and its Apache server. but now i can't login to the Configuration and Settings Migration Wizard....
    3. Login to Admin page = No Navigation links
      Using CFMX 6.1 w/ IIS 5. Last week I was messing w/ the default WWW security settings SSL etc and now when I login into the admin page...
    4. Login to admin system through login screen only
      Hi there, I have an issue relating to login to my asp.net application. Basically i have built the standard login page which compares against the...
    5. Admin login lost user name pw HELP!!
      I created user accounts and myself as admin. I disabled fast access so that no one could see the userlist since user accounts did not need...
  3. #2

    Default Re: user and admin login on same login page

    I would suggest that you start with a <cfparam ="MM_redirectLoginSuccess"
    default=""> instead of setting it to members.
    After the query use the <CFIF> to check the specific permission
    cfif Session.MM_Permissions Is "user">
    <cfset MM_redirectLoginSuccess="members.cfm">
    and whatever else you need to add for members
    <CFELSEIF Session.MM_Permissions Is "admin">
    <cfset MM_redirectLoginSuccess="admin.cfm">

    This little piece of code worries me:
    <cfif Session.MM_Permissions NEQ "user">
    What if the you decide to add a new permission type (ie: someone needs read
    only to reports) or the permission type is left blank by accident- according to
    your code they will default to the administrator level!
    I have a login page that sends them to their respective page and have never
    had a problem with the security of it. I run them through the cfif/cfelseif to
    define all the different permissions.
    (If you are using the cfquery, remember to use the cfqueryparam tag. <cfquery
    name="MM_rsUser" username="---------" password="--------"
    datasource="---------">
    SELECT * FROM users WHERE username= <CFQUERYPARAM Value="#FORM.id#">AND
    password=<CFQUERYPARAM Value="#FORM.pw#">
    </cfquery>

    Hope this helps.
    J


    jmj 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