I have a security framework in place for both users + admins (module). I have 2 layouts
Main
Admin
I have this code shoved in the top of the template and it works but I love to refactor. So my question to you guys is where is the appropriate place for this code to go? This grabs the username of the logged in user and displays it in the layout, if they are not logged in defaults to guest user
<cfset user = getPlugin(‘sessionStorage’).getVar(‘user’)>
<cfif isStruct(user) and structKeyExists(user,‘fullname’)>
I'd just set username in session with OnSessionStart and default it to
"Guest User". Then on your login processing logic, set
session.username to whatever you want for the logged in user. Then
just refer to session.username (or use the sessionStorage facade
plugin like your code uses, as per your own preference) when you need
to output it.
Judah
i guess i am just wondering where that kind of logic would go because I have other things i check… I am guessing a request context decorator but I have limited experience with that so I thought I would ask
<cfset user = getPlugin(‘sessionStorage’).getVar(‘user’)>
<cfif isStruct(user) and structKeyExists(user,‘fullname’)>
Extend the security interceptor and put vars in prc scope.
I'm using custom interceptor points e.g.
loginSuccess,loginFailed,logOff