I'm trying to get a context named userAdmin from within the handlebars framework for AEM Social Communities. The userAdmin context checks if the logged in user is a member or a moderator.
We already have this code within /libs/social/console/components/hbs/sitenavbar/sitenavbar.hbs at line number 54. With the below userAdmin context the Administration link appears only if the logged in user is a moderator/Community Admin
{{#if userAdmin}}
<li>{{i18n "Administration"}}</li>
{{/if}}
Problem
I'm not able to fetch the same userAdmin context within /libs/social/messaging/components/hbs/messagebox/buttons.hbs at line number 36 where I want to the new message button only if the logged in user is a moderator/Community Admin
{{#if userAdmin}} //Here the context is not available within the buttons.hbs
<input type='submit' class='actionbuttons' id='newMessageButton' name='{{properties.replyURL}}' value='{{i18n "+ New Message"}}' />
{{/if}}
Could you please help me to figure out a way to get the context available in sitenavbar to any other SCF component like messagebox or forums. I've also tried using options like {{../userAdmin}} and {{#root userAdmin}}
Any suggestion or help would be great.
This data (or getter) is exposed through the SocialComponent for this resource type. Only few objects are implicit available globally. So you need to define your own social component and implement (or extend existing component if some bundle exports it) such a getter. You can refer to the example scf projects (for example here) in github or look also in the adobe documentation.
You can find all objects available in the context of the current path by appending .social.json (e.g. /content/community-components/en/forum/jcr:content/content/forum.social.json).This will expose all the variables (context) that can be used inside the template.
Related
When we deploy a Custom template in Azure then a few parameters like Resource Group and Region are automatically popped up in the Azure portal (see the attached screenshot). I want to know how can we customize or restrict the list of regions using ARM templates.
Edit
The first "region" dropdown is for the resourceGroup's location - it's required when creating a new one, disabled when using an existing one. For a custom template, you cannot customize or remove that control unless you provide your own ui definition file.
That said, there's also nothing that requires you to use the value from that control in your deployment. If you want to use that value you'd reference it using resourceGroup().location in your template. That would allow you to remove the "duplicate" but also requires that the resources are deployed to the same region as the resourceGroup.
For your own "region" control, you can use the allowedValues property on the parameter in the template and that will restrict the items in the list to what you provide - that's the link that Jim provided in the comment above.
If you supply your own ui definition file there are more things you can do to restrict the list, but requires you to write a bit more code. This would be the starting point:
https://learn.microsoft.com/en-us/azure/azure-resource-manager/managed-applications/create-uidefinition-overview
The docs talk about managedApplications, but the ui is a generic construct that you can use for template deployments, here's a generic example:
https://github.com/Azure/azure-quickstart-templates/tree/master/100-marketplace-sample
[edits post comment]
If you want to leverage the "built-in" region control you can customize the list of locations that appear there by setting the config in the createUiDefintion.json file. More on that here:
https://learn.microsoft.com/en-us/azure/azure-resource-manager/managed-applications/create-uidefinition-overview#config
I try to manage the access rights for users to edit or view different articles.
Articles can be created dynamically and the rights should be editable for every article.
In my case, I have a User object and multiple other objects (Article, and more...).
I need to check if a User can read or write any kind of object.
I actually see there is a method Voters, but they only can manage User groups?
Can somebody help me?
A Voter can decide almost anything - usually it's based on a user's permission, but it doesn't have to be - I've used one as a 'feature flag' check, with a value fetched from a configuration, or database entry to show something - or not, as an example.
The page on voters has an example on viewing, or editing a database record (a Post entity, via a $this->denyAccessUnlessGranted('edit', $post);.
In your instance, the voter would be passed the 'attribute', the object (Article, etc) you want to check on, and gets the current user from a service. If that user has the appropriate permission to read/edit/delete the Article or other object, it returns true.
I have two pages/Template,
Dashboard (contains some User specific data as well).
Users.
I am using Meteor 1.5 with Blaze Template. Landing Page is Dashboard. I am using the common subscription for Collection Users in both Templates.
Scenario 1
When I use Meteor.subscribe('Users') in Dashboard's template.onCreated() and go to Users page, I see some already subscribed data coming back from Dashboard's subscription.
CODE:
Template.DashBoard.onCreated(function(){
Meteor.subscribe('Users');
});
Template.Users.onCreated(function(){
Meteor.subscribe('Users');
});
Scenario 2
When I use this.subscribe('Users') in Dashboard's template.onCreated() and go to Users page, I get a Fresh Subscription happening here and no data carry over from Dashboard's subscription.
CODE:
Template.DashBoard.onCreated(function(){
this.subscribe('Users');
});
Template.Users.onCreated(function(){
this.subscribe('Users');
});
Question
What is the difference between Meteor.subscribe('Users') and this.subscribe('Users') ? What can be the impact of using this.subscribe('Users') ?
As explained in Meteor documentation, this.subscribe within Template code will be automatically unsubscribed when the template instance is destroyed.
Whereas Meteor.subscribe needs to be explicitly unsubscribed if you want it to.
The decision to use one or the other depends on your app structure. If you are sure the data is relevant only for a given template, then use template scoped subscription, i.e. this.subscribe.
If the data is used across several pages, either use the "global" form, or scoped at a higher template level (one that persists through your pages, e.g. on layout).
On Plone 4.3.7, as per Products.Membrane & dexterity.membrane instructions, I've added a CustomMember & CustomGroup content type and assigned them the proper behaviors. After adding instances of them, going to membrane_tool, adding those types (seems this was required) to the selection of membrane content and reindexing, instances of custom member types show up in membrane_tool catalog.
However, groups do not show up (in membrane_tool catalog). Neither do the groups show up in the regular site management Users/Groups UI, but I guess that's to be expected (given they are not catalogued).
Neither can I log in using the credentials entered when adding CustomMember instances.
What additional steps are there to make custom Dexterity-based Users & Groups work? Is the group assignment done by containment (ie. a CustomUser must be added inside a CustomGroup) or via some other mechanism? And how are roles assigned?
P.S. I've also tried out the example member content type provided by dexterity.membrane, but trying to add that results in an error.
The default implementation expects the membrane user to have a "enabled" workdflow state.
I need to extend asp:Menu to support linking to MVC routes (my project has a mix of MVC and non-MVC pages). My menu is generated using a custom class which determines if a user should be shown a node based on their priveleges to the file it referes to.
MVC pages are restricted using the AuthorizeAttribute. Avoiding mocking (if possible) I want to
Determine if the path refers to an MVC page or a standard page
If MVC, determine if the user has the rights to access it
Here's my method signature inside the menu generation class:
Private Function CanAccessPage(path As String) As Boolean
Here's the algorithm I used for this,
Based on #SLaks answer here, I was able to determine if the path referred to an MVC route.
If it was MVC, I grabbed the controller type (this required knowing what namespace my controller's were in)
Got the action method by controllerType.GetMethods(actionMethodName) (if you have multiple methods with the same name, you must pick the one your link refers to. Probably the one with an HttpGet attribute).
Used actionMethodInfo.GetCustomAttributes(GetType(AuthorizationAttribute), False) to get a collection of all authorization filters for the specified action
Called OnAuthorization with the fake context info I build in step 1 for each attribute.
Check if TypeOf filterContext.Result Is HttpUnauthorizedResult and return accordingly