ZFA Scaffold Update – Authenticating a Page

Last week a nice guy named Greg reached out to me about the ZANS scaffold I created and how he was enjoying it. He also ran into an issue where the reload of a view wasn’t properly checking user credentials. He found a simple trick to fix this which I wanted to share really quick.



The simple trick is to check the authentication object again when the controller initializes itself. You’ll find that sometimes when you rebuild your .Net app, or fire up the browser for the first time the browser retains an older cookie, even though it has expired, so some of your “logged in” items are still visible. By running a simple auth check again, we can eliminate that problem on the client side. To accomplish this, we include the location and authService directives into the controller. Here’s what the updated News controller looks like:

That’s all there is to it! If you have one or two controllers, this will work just fine. For anything larger, we’ll want to push this code into the main application definition, and potentially intercept the route change event. I’ve done something similar in a previous iteration of a project, so once I get it migrated in I’ll post another update.


Thanks Greg!


What are your 10 bits on the matter? I want to know!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s