I am trying to visualize the Login Process for a CFC I am trying to
create.  I am new to the idea of "OOP" in CF and might need a big knock
in the head once you see the problem.

 

I want to manage all of the Users Information in the Session Scope so
that I can access the information from any page and create a more
complex set of user authorization.

 

Here is what I have so far.  I have taken the idea of this out of the
fb41bookstore sample from Brian Kotek's website.  His example is a
shopping cart and mine is user login so that is one reason why I can't
visualize this...

 

(This application is in the ModelGlue framework)

loginManager.cfc

 

<cfcomponent displayname="Session Facade for User Login"
hint="loginManager">

 

            <cffunction name="init" access="public"
returntype="coe_worm.controller.loginController" output="false"
hint="User Login Constructor.">

                        <cfreturn this />

            </cffunction>

            

            <cffunction name="paramUser" access="public"
returntype="void" output="false" hint="If session.user does not exist,
create it.">

                        <cfif not structKeyExists( session, 'user' )>

                                    <cflock scope="session" timeout="10"
type="exclusive">

                                                <cfif not
structKeyExists( session, 'user' )>

                                                            <cfset
session.user = createObject('component', 'coe_worm.model.login').init()
/>

                                                </cfif>

                                    </cflock>

                        </cfif>   

            </cffunction>

            

            <cffunction name="getUser" access="public"
returntype="coe_worm.model.login" output="false" hint="Return the user
object.">

                        <cfset paramUser() />

                        <cflock scope="session" timeout="10"
type="readOnly">

                                    <cfreturn session.user />

                        </cflock>           

            </cffunction>

            

            <cffunction name="login" access="public"
returntype="coe_worm.model.login" output="false" hint="Login">

                        <cfargument name="username" required="true" />

                        <cfargument name="password" required="true" />

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset
session.user.login(arguments.username, arguments.password) />

                        </cflock>

                        

            </cffunction>

            

            <cffunction name="setDisplayName" access="public"
returntype="void" displayname="Set Display Name" output="false"
hint="Set the display name of the user.">

                        <cfargument name="displayname" type="string"
required="yes" />

                        <cfset paramUser() />

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset
session.user.setDisplayName(arguments.displayname) />

                        </cflock>

            </cffunction>

            

            <cffunction name="setIsLoggedIn" access="public"
returntype="void" displayname="Set Is Logged In" output="false"
hint="Set the logged in status of the user.">

                        <cfargument name="isLoggedIn" type="boolean"
required="yes" />

                        <cfset paramUser() />

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset
session.user.setIsLoggedIn(arguments.isLoggedIn) />

                        </cflock>

            </cffunction>

            

            <cffunction name="setUserGroups" access="public"
returntype="void" displayname="Set User Groups" output="false" hint="Set
the user groups of the user.">

                        <cfargument name="userGroups" type="string"
required="yes" />

                        <cfset paramUser() />

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset
session.user.setUserGroups(arguments.userGroups) />

                        </cflock>

            </cffunction>

            

            <cffunction name="getDisplayName" output="false" hint="Get
the user's display name.">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset userDisplayName =
session.user.getDisplayName() />

                        </cflock>

                        

                        <cfreturn userDisplayName />

            </cffunction>

                        

            <cffunction name="getIsLoggedIn" output="false" hint="Get
the variable to see if the user is logged in.">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset IsLoggedIn =
session.user.getIsLoggedIn() />

                        </cflock>

                        

                        <cfreturn IsLoggedIn />

            </cffunction>

            

            <cffunction name="getUserGroups" output="false" hint="Get
the user's groups.">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                                <cfset userGroups =
session.user.getUserGroups() />

                        </cflock>

                        

                        <cfreturn userGroups />

            </cffunction>

            

</cfcomponent>

 

Login.cfc:

<cfcomponent displayname="User Login" hint="User Login Component">

            <cffunction name="init" returntype="coe_worm.model.login"
output="false">

                        <cfparam name="variables.user"
default="#structNew()#" />

                        <cfreturn this />

            </cffunction>

            

            <cffunction name="getUser" access="public"
returntype="coe_worm.model.login" output="false" hint="Return the user
object.">

                        <cfreturn this />

            </cffunction>

            

            <cffunction name="login" output="false">

                        <cfargument name="username" type="string"
required="true" />

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

                        

                        <cftry>

                                    <cfset iamgood = "yes">

                                    <cfset longUserName =
arguments.username & "***">

                                    <cfset myfilter =
"userPrincipalName=" & longUserName>

                                    <cfldap ...>

                                    <cfcatch type="any">

                                                <cfset iamgood = "no">

                                    </cfcatch>

                        </cftry>

                        

                        <cfif iamgood eq "yes">

                                    <cfset LoggedIn = true>

                                    <cfoutput query="getinfo">

                                                <cfset UserGroups = "">

                                                <cfloop index="myx"
from="1" to="#listlen(memberof)#">

                                                            <cfif
trim(listgetat(listgetat(memberof,myx),1,"=")) eq "CN">

 
<cfset UserGroups = UserGroups &
listgetat(listgetat(memberof,myx),2,"=") & ",">

                                                            </cfif>

                                                </cfloop>

                                                <cfset UserGroups =
mid(usergroups, 1, len(usergroups)-1)>

                                                <cfset fname =
givenname>

                                                <cfset lname = sn>

                                                <cfset displayname =
getinfo.displayname>

                                    </cfoutput>

                        <cfelse>

                                    <cfset LoggedIn = false>

                                    <cfset UserGroups = "">

                                    <cfset displayname = "">

                        </cfif>

                        

                        <cfset LogIn = StructNew()>

                        <cfset LogIn.LoggedIn = #LoggedIn#>

                        <cfset LogIn.UserGroups = #UserGroups#>

                        <cfset LogIn.displayname = #displayname#>

                        

                        <cfreturn LogIn>

            </cffunction>

            

            <cffunction name="setUserGroups" output="false" hint="Set
the user's groups.">

                        <cfargument name="value" type="string"
required="true">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset session.user.UserGroups =
arguments.value>

                        </cflock>

            </cffunction>

            

            <cffunction name="setIsLoggedIn" output="false" hint="Set
the variable to see if the user is logged in.">

                        <cfargument name="value" type="boolean"
required="true">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset session.user.IsLoggedIn =
arguments.value>

                        </cflock>

            </cffunction>

            

            <cffunction name="setDisplayName" output="false" hint="Set
the user's display name.">

                        <cfargument name="value" type="string"
required="true">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfset session.user.DisplayName =
arguments.value>

                        </cflock>

            </cffunction>

            

            <cffunction name="getUserGroups" output="false" hint="Get
the user's groups.">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfreturn session.user.UserGroups>

                        </cflock>

            </cffunction>

            

            <cffunction name="getIsLoggedIn" output="false" hint="Get
the variable to see if the user is logged in.">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfreturn session.user.IsLoggedIn>

                        </cflock>

            </cffunction>

            

            <cffunction name="getDisplayName" output="false" hint="Get
the user's display name.">

                        <cflock scope="session" timeout="10"
type="exclusive">

                                    <cfreturn session.user.DisplayName>

                        </cflock>

            </cffunction>

            

</cfcomponent>

 

What am I missing?  Or am I doing this correctly?

 

Thanks,

Seth



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:210493
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to