Welcome Guest, Not a member yet? Register   Sign In
Do I have to add authentication validation to the view files, too?
#1

[eluser]bastones[/eluser]
Hi,

This may sound like a stupid question for experienced folks. In my controllers I have authentication checks so users going to, say, 'members/index' for the members area are redirected to 'members/login' if they're not logged in. However, do I have to add the same sort of authentication checks to the view file that is used for 'members/index' as well? Or can view files not be accessed any other way so I don't need to?

Thanks,
Ben.
#2

[eluser]cideveloper[/eluser]
You do not need to add authentication to the view files. The controller will take care of this. The only aspect of auth that you would normally have in a view file is access control based on membership type. Lets say you had a menu in your view, and you only wanted certain links to show for administrators you would have code like this in you view.

Code:
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
&lt;?php if (is_admin()) : ?&gt;
<li><a href="#">Link 1</a></li>
&lt;?php endif; ?&gt;
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>




Theme © iAndrew 2016 - Forum software by © MyBB