2 Replies Latest reply on May 12, 2008 9:22 AM by Michael Borbor

    CFLOGIN

    cliffy2009
      Hey guys,
      I have been working on this all weekend and I can get the CFLOGIN to work.
      This is my code:
      <cfcomponent>

      <cffunction name="loginuser" access="remote" returntype="struct">
      <cfset var person = StructNew()>
      <cfset person.login = "false">
      <cfset person.name = "none">
      <cfset person.role= "none">

      <cflogin idletimeout="0"> <!---user will be logged out automatically after 3 minutes of inactivity--->

      <cfif isDefined("cflogin.name") AND isDefined("cflogin.password")>

      <cfif cflogin.name EQ "admin" AND cflogin.password EQ "admin">

      <cfloginuser name="#cflogin.name#" password="#cflogin.password#"
      roles="admin">

      <cfset person.login = "true">
      <cfset person.role = "admin">

      </cfif>

      <cfif cflogin.name EQ "user" AND cflogin.password EQ "user">

      <cfloginuser name="#cflogin.name#" password="#cflogin.password#"
      roles="user">

      <cfset person.login = "true">
      <cfset person.role = "user">

      </cfif>


      <cfif person.login EQ "true">

      <cfset person.name = getPersonName(cflogin.name, cflogin.password)>

      </cfif>

      </cfif>

      </cflogin>

      <cfreturn person>

      </cffunction>

      <cffunction name="logoutuser" access="public">
      <cflogout>
      </cffunction>

      <cffunction name="getAdminData" access="public" roles="admin" returntype="string">
      <cfreturn "Some Secure Admin Data!">
      </cffunction>

      <cffunction name="getUserData" access="public" roles="user,admin" returntype="string">
      <cfreturn "Some Secure User Data">
      </cffunction>





      <cffunction name="getPersonName" access="private" returnType="String">

      <cfargument name="loginName" type="string" required="true">
      <cfargument name="password" type="string" required="true">

      <cfset personName = "none">

      <!---hard coded for now, TODO look up in database--->

      <CFQUERY NAME="qSecurity" DATASOURCE="Student_IS">
      SELECT memID, memFirstName, memLastName, memUserName, memPassword, RoleName FROM Member
      WHERE memUserName = '#cflogin.name#' and memPassword = '#cflogin.password#'</CFQUERY>
      <cfif qSecurity.recordCount EQ 1>
      <CFLOGINUSER NAME = "#cflogin.name#"
      PASSWORD = "#cflogin.password#"
      ROLES = "#trim(qSecurity.RoleName)#">
      </cfif>




      <!--- <cfif arguments.loginName EQ "admin" AND arguments.password EQ "admin">

      <cfset personName = "Bruce">


      <cfelseif arguments.loginName EQ "user" AND arguments.password EQ "user">

      <cfset personName = "Mary">

      </cfif>--->

      <cfreturn QSecurity>

      </cffunction>

      </cfcomponent>

      I don't know why I can't get it to work. Can someone tell me what I am doing wrong. I am trying to authenticate from a database. Please, Help!!!!

      Thank you for your response

      If you have a working code, can you email it to me?