You should be able to control this using Member groups - On the "Images" node you setup protection and only allow members of certain groups.
Then in your razor rendering you can check if an item is restricted or accessible by all.
The same goes for "Documents" but you will need to group them in "public" and "Restricted" childs...if you need to hide some of the restricted documents for certain members but make them visible for other members you need to have more user groups and a structure that allows you to specify that certain documents in the restricted area are only visible for a certain group as well.
All Members belong to one or more Roles.
You can easily set up new roles in the Members Dashboard.
If you right-click on a page in the content tree, you can select Public Access => Role based, where you can specify the roles which have access to the page.
You can also check if a member is in a role or group or whatever in the code with MembershipHelper.IsMemberAuthorized().
If you want to do checks (i.e. Documents) for specific members, you can do something like this in your controller:
Document myDocument = ....
if (!Members.IsLoggedIn() || Members.GetCurrentMember().Id != myDocument.CreatorId)
{
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
}
Is this the way to structure it? Or do you have a better surgestion?
Home (all)
- News (all)
- Images (private)
--- Ryan
--- Sophie
--- James
- Calendar (all)
- Documents (some for all / some private)
--- Shared
--- Ryan
--- Sophie
--- James
I tried doing it, but it does not seem to work. I added role based protection to the parent nodes and it doesnt work.
Home - access for all members
- News
- Images
- Calendar
- Documents
--- Shared - no protection other than from the top level node
----- node
----- node
----- node
--- Ryan - Added protection for first group
----- node
----- node
----- node
--- Sophie - Added protection for second group
----- node
----- node
----- node
Ok - Don't know if it will work but could you try to upgrade to 7.2.2? I think the above code looks fine and should be working...but have not tried doing it in Razor before though.
"I am making a website, where there is a login protected members area. I know how to make that, so that is not the problem."
But i do not know how to do this, and I don't find anything about it in the internet, can anyone help me? How should I make private area? Via code, or via CMS? Thank you all!
How to make shared and private content?
Hello!
I am making a website, where there is a login protected members area. I know how to make that, so that is not the problem.
I want some information to be visible to all members and some information to be visible to only one or a few members. See example below.
How do I set this up, in the best possible way?
Using u7 and Razor.
Thank you for your help!
Daniel
Hi Daniel
You should be able to control this using Member groups - On the "Images" node you setup protection and only allow members of certain groups.
Then in your razor rendering you can check if an item is restricted or accessible by all.
The same goes for "Documents" but you will need to group them in "public" and "Restricted" childs...if you need to hide some of the restricted documents for certain members but make them visible for other members you need to have more user groups and a structure that allows you to specify that certain documents in the restricted area are only visible for a certain group as well.
I hope this makes sense? :)
/Jan
You should be able to check for access using a combination of .HasAccess() .IsProtected() btw.
/Jan
All Members belong to one or more Roles.
You can easily set up new roles in the Members Dashboard.
If you right-click on a page in the content tree, you can select Public Access => Role based, where you can specify the roles which have access to the page.
You can also check if a member is in a role or group or whatever in the code with
MembershipHelper.IsMemberAuthorized()
.If you want to do checks (i.e. Documents) for specific members, you can do something like this in your controller:
Hope this helps, bye Tobi
Thank you both! I'll give it a try!
Just a quick question.
Is this the way to structure it? Or do you have a better surgestion?
Thank you!
Daniel
Hi Daniel
I think that structure looks fine and it should work fine as well :)
/Jan
Thank you! :-)
Hi again
I tried doing it, but it does not seem to work. I added role based protection to the parent nodes and it doesnt work.
Here is my partial view:
When the if.HasAccess is not here, everything is shown, but when there, nothing is shown.
Can you guys see, where I am going wrong?
Thank you for your help! :-)
Daniel
Hi Daniel
Are you logged in as either of the groups when nothing is shown? And what exact version of Umbraco 7 are you using?
/Jan
Yes, I am logged in.
I am using the second newest version. Don't remember the number. :-)
Daniel
Hi Daniel
Ok - Don't know if it will work but could you try to upgrade to 7.2.2? I think the above code looks fine and should be working...but have not tried doing it in Razor before though.
/Jan
Hi Jan
It did not work, but it was worth a try :-)
Thanks!
Daniel
Hello Daniel,
I see that you wrote:
"I am making a website, where there is a login protected members area. I know how to make that, so that is not the problem."
But i do not know how to do this, and I don't find anything about it in the internet, can anyone help me? How should I make private area? Via code, or via CMS? Thank you all!
Hi Shlomit,
Try working through my blog posts:
That should cover what you need. Any questions - start a new thread !
Hope that helps
Steve
is working on a reply...