Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# jmaynor 5/2/2005 11:56 AM
During the AuthenticateRequest event of the ASP.NET page lifecycle the HTTP Module AuthenticationModule's Context_Authenticate(object sender, EventArgs e) is called.

In this method a Cuyahoga.Core.Domain.User is returned (either from Cahce or the database). Then that user is 'attached' to the 'current' NHibernate session with the code:

this._activeSession.Lock(obj, LoclMode.None);

where obj is a reference to the user created in Context_Authenticate.

Can you explain what this is?

Jeremy
# martijnb 5/2/2005 3:56 PM
Cuyahoga uses its own User class as identity instead of a FormsIdentity or a GenericIdentity. This way you can easily utilize the behaviour of the User class. For example: when loading a node and you want to do a permission check, you can always grab the user instance from the context (Page) and check if the user has access to a node simply with: this._activeNode.ViewAllowed(Page.User.Identity).

Since Cuyahoga caches the entire site structure, all permission checks can be done this way without querying the database (after the initial loading of course).

Session.Lock() is needed when the user comes from the cache. After retrieving an object from the cache, it doesn't know of any NHibernate session, and the User object always needs a session because of the lazy loaded list of roles.
# jmaynor 5/3/2005 5:02 AM
So, the user object has to be associated with a session for it's lazy loaded members, but what does Session.Lock do?
# martijnb 5/3/2005 6:19 AM
jmaynorSo, the user object has to be associated with a session for it's lazy loaded members, but what does Session.Lock do?

Well, that's exactly what Session.Lock does :)