1) Most of the end-tags are unnecessary. For example, you may
use
<cfreturn getUserGroups.groupID> in place of
<cfreturn getUserGroups.groupID />. In any case, it is
advisable to have a space before such an end-tag slash.
2) If a function returns, you must declare its return type
<cffunction access="public" name="authorize" output="0"
returntype="string">
<cffunction access="public" name="authenticate" output="0"
returntype="string">
3) Modify the returned variables accordingly
<!--- function "authenticate" --->
<cfif checkAuthentication.recordCount>
...etc...
<cfreturn checkAuthentication.username>
<cfelse>
<!--- Remember that you will be testing if
Len(returnedVar) EQ 0 --->
<cfreturn "">
</cfif>
<!--- function "authorize" --->
<!--- return the appropriate groupID(s) --->
<cfif getUserGroups.recordCount>
<cfreturn getUserGroups.groupID>
</cfif>
<!--- if recordcount is 0, return blank string --->
<cfreturn "">
</cffunction>
4) The following code contains two errors. It implies that
groupID is an attribute of cfinvoke, which is not true. It also
does not pass the required parameter, cfcUsername.
<cfinvoke component="security"
method="authorize"
returnVariable="groupID"
groupID="#getUserGroups.groupID#">
I'm guessing your intention is to do
<cfinvoke component="security" method="authorize"
cfcUsername="#form.username#" returnVariable="grpID" />
<cfset groupID="#grpID#"><!--- the returned
string--->
5) The following passage seems to repeat a theme
<cfif structKeyExists(form,"checkAuth")>
<!--- The user pressed the authenticate button --->
<cfinvoke
component="security"
method="authenticate"
returnVariable="authenticated"
cfcUsername="#form.username#"
cfcPassword="#form.password#">
<cfif len(variables.authenticated)>
<!--- now get their groupID --->
<cfinvoke component="security"
method="authorize"
returnVariable="groupID"
groupID="#getUserGroups.groupID#">
</cfif></cfif>
<cfif isDefined("variables.authenticated")>
<cfif variables.authenticated NEQ 0>
<b>Username and Password Authenticated Successfully!
<cfoutput>#variables.groupID#</cfoutput></b>
<cfinvoke
component="security"
method="authorize"
returnVariable="authorize"
cfcUsername="#form.username#">
<cfelse>
<b>Username and/or Password was incorrect!</b>
</cfif>
</cfif>
Tighter is:
<cfif structKeyExists(form,"checkAuth")>
<cfinvoke
component="security"
method="authenticate"
returnVariable="authenticated"
cfcUsername="#form.username#"
cfcPassword="#form.password#">
<cfif len(variables.authenticated)>
<b>Username and Password Authenticated
Successfully!</b>
<!--- now get their groupID --->
<cfinvoke
component="security"
method="authorize"
cfcUsername="#form.username#"
returnVariable="grpID" />
<!--- display returned string --->
<cfif Len(grpID) GT 0>
GroupID = <cfoutput>"#grpID#"</cfoutput>
<cfelse>
No GroupID for user
</cfif>
<cfelse>
<b>Username and/or Password was incorrect!</b>
</cfif>
</cfif>
6) Have you had a look at
a
previous suggestion for your CFC?
added edit:
correction for function, "authorize". It should return a string,
the GroupID, not a query. Thanks, Hydrowizard.