You're welcome. And you're indeed doing it right :-) This is one of the many things I like about Umbraco, that you can use the default .Net membership provider to manage security/access.
Hi. Using the HasAccess property this way keep in mind that there could be some performance issues in case there're lots of child nodes. (By implementation this property queries the database every time being called).
Hi. Actually I cannot offer the best and only solution for this case at once. Personally right now I'm up to the site that's going to be intended primarily for using by registered members and I feel like the performance can become an issue under load. I haven't yet done any research on it like load tests or like that, but I suppose we will always be able just to wrap the umbraco membership provider with a custom implementation that adds some caching in case we get performace problems with membership.
Check if user/member HasAccess...
Hi there,
Im trying to see if user has access. The only way I fund is as follow:
Is there a better way than this?
Cheers
mkariti
Hi mkariti,
This is indeed the default way of doing, using the default membership provider functionalities.
Is there a specific reason why you would to do it in another/better way?
Cheers,
Michael.
Hi Michael,
No that is fine! Just checking that Im doing right!
Many thanks for your quick reply!
Cheers,
mkariti
Hi mkariti,
You're welcome. And you're indeed doing it right :-) This is one of the many things I like about Umbraco, that you can use the default .Net membership provider to manage security/access.
Cheers,
Michael.
Hi Mkariti
Try this example
@foreach(var item in Model.Children)
{
if(item.HasAccess())
{
@item.Name
}
}
Yarik.
Wow many thanks Yarik!
Works like a charm!
Hi. Using the HasAccess property this way keep in mind that there could be some performance issues in case there're lots of child nodes. (By implementation this property queries the database every time being called).
http://our.umbraco.org/forum/core/general/29722-Lot's-of-SQL-queries
Hi Rodion Novoselov,
Many thanks for the heads up!
Any idea on should I implement the HasAccess to check if a member indeed has access to view the item?
Cheers
mkariti
Hi. Actually I cannot offer the best and only solution for this case at once. Personally right now I'm up to the site that's going to be intended primarily for using by registered members and I feel like the performance can become an issue under load. I haven't yet done any research on it like load tests or like that, but I suppose we will always be able just to wrap the umbraco membership provider with a custom implementation that adds some caching in case we get performace problems with membership.
About the HasAccess. I tried in V5.1 this code with HasAccess as method and as property, but I can't get it to work. Am I doing something wrong?
it is answered in this thread: http://our.umbraco.org/forum/core/umbraco-5-general-discussion/30824-Restricting-access-to-pages?p=0#comment115580
is working on a reply...