> Ray,
>   What about a situation where you have certain display
> elements that only show to logged-in users?  Why not wrap
> <cflogin> around those elements?  I know you're immediate
> answer is "use conditional logic to see if
> getAuthUser()returns an empty string", but I don't see why
> one is better than the other.  Using getAuthUser() means
> using conditional logic (yes, I know that <cflogin> is an
> explicit conditional check) which is more sore on the eyes
> and requires a developer to expend more thought in order to
> figure out what the conditional logic is.  <cflogin> is
> intended to be wrapped around code to run when people aren't
> logged in.  GetAuthUser() is supposed to return the name of
> the logged-in user.  Right now, getAuthUser() happens to
> return an empty string when you're not logged in, but that
> functionality
> isn't set in stone.   If that functionality is set in stone,
> I still think
> <cflogin> leaves less doubt about the intention of the code.  
> Thoughts?
>

In my mind, <cflogin> should not be used as a login check. It should only be
used to manage the login system as whole. Sure it _acts_ a bit like a
conditional check, but that is not its true purpose. This to me is enough to
say that getAuthUser is better than <cflogin> for determining if a user is
logged in.

Why do you say GetAuthUser() is not set in stone? That can be applied to
_any_ function. Even if MACR changed it so that users not logged in returned
XXX or somesuch, you could use use it as a way to see if the user is
authenticated.

As a side note, you _can_ use <cflogin> to determine if the user is logged
in. For a site where logins are optional, you can have this in
Application.cfm:

<cflogin>
<cfset request.userisloggedin = false>
<!--- normaly code here o handle potential log ons, and set the
request var above to true if need be --->
</cflogin>

someotherfile.cfm:

<cif request.userisloggedin>
.....
</cfif>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to