How to fix the error "You are not authorized to create, modify or lock instance error"? - pega

I have the data page DestrAct.
When I try to call Obj-Save method in an activity the error "You are not authorized to create, modify or lock instance Org-Div-Data-DestrAct" occurs.
Why does it happen and how can I fix it?
Thank you.

To fix the error:
Open your Access group. You will see an Access roles List.
Open any Access role. You will see a table of Privileges.
Click on Add icon(+). A section will pop up.
At the top, put you class name Org-Div-Data-DestrAct.
In middle Privileges section put 5 in all 8 input fields.
Leave the bottom Privileges and Access section blank.
Re-login.
Now you should be able to create and update instances of Org-Div-Data-DestrAct

Related

Is there any way to attach the current data (as a .csv file) in PloneFormGen to a mailer?

We use PloneFormGen 1.7.12 using Plone 4.3.3. I have a request to include the current data in the email that the form is sending. We normally give editors access to the data to download, but the people he wants to send these to are not editors and I don't want to give them editor's permissions.
If it can't be added to the mailer, I guess I could create a role and give it just enough permissions for an authenticated user to download data. Would it work to copy the authenticated permissions over to a new role and add the PloneFormGen: Download Saved Input permission as well? I really don't like creating extra roles. In addition we would need to set up accounts for these people.
AFAIK not without coding :-)
Create a new DataSaveAdapter content type
Best way ist to inherit from the existing one and add a new field:
from Products.PloneFormGen.content.saveDataAdapter import FormSaveDataAdapter
SendDataAdapterSchema = FormSaveDataAdapter.schema.copy() + atapi.Schema((
atapi.StringField(
name='csv_recipients',
required=False,
widget=atapi.LinesWidget(
label=_(u'label_csv_recipients', default=u'CSV recipients'),
)
)
))
class SendDataAdapter(FormSaveDataAdapter):
implements(IPloneFormGenActionAdapter)
...
schema = SendDataAdapterSchema
...
The SaveDataAdapter provides a onSuccess method, where you can hook in and send your email
class SendDataAdapter(FormSaveDataAdapter):
...
def onSuccess(self, fields, REQUEST=None, loopstop=False):
""" saves input data and initiates mail"""
super(SendDataAdapter, self).onSuccess(fields, REQUEST, loopstop)
self.send_csv() # This is where you may implement sending the email.
Of course it needs some work to get it done (registering content type, etc.), but this should point you in the right direction.
Not really sure about your requirements, but in case you want to send the single-record in CSV-format as a mail when a form is submitted, you can customize the template of the mailer-adapter, like this:
<tal:block repeat="field options/wrappedFields | nothing">
"<span tal:replace="structure python:field.htmlValue(request)" />",
</tal:block>
Note, that this only works, if the mail's format is HTML, in plain text tal:repeat comes in the way, adding linebreaks between the values.
If you want to give a group of users permissions to view and download a save-adapter, go to PFG's controlpanel (append /prefs_pfg_permits to the site's URL), where it says "Download Saved Input" check the box for "Reader", then assign "Can edit"-permissioins via the sharing-tab of your save-adapter to the users and groups you want to be privileged.

Registering new users via OAuth2 : what to set as user identifier for future log ins?

I have managed to successfully configure this. The problem is, when I change the lines below :
//I have set all requested data with the user's username
//modify here with relevant data
$user->setUsername($username);
$user->setEmail($username);
$user->setPassword($username);
into the information I want to retrive, such as real name, email, my generated password etc, when I click the Login button for Facebook per say, I am asked again if I want to connect with my local testing site.
From what I understand, in the documentation I linked above, this :
$user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
is the line that checks if the user exists or not, and the initial code by itself, sets either facebook_id or twitter_id (this is how I save them) as a new User *username*. If I change the line
$user->setUsername($username); //same as facebook/twitter _id
into
$user->setUsername(setProperUsername()); //sets a proper unique username
Then everytime I try to login I get the "Register" message. So, I have a general idea of how it works but I am having a hard time understanding some things:
1. When I have registered with Facebook and I login with twitter, I register again, no knew row is created, but missing twitter_id fields are updated/populated, username stays intact. How come HWI/FOSUB knows I am the same person when my previous data were from Facebook not Twitter?
2. If there is a global way of knowing I am the same person, what data from the $response object should I use as a key to identify already registered users?
After testing a lot with this, I have the answer if anyone runs into this type of situation
Check your default_target path, make it so it is /profile, /account etc, don't default to login again. Also, if a user is already logged in, do not make him access your login page. This was why my data was being updated. I was basically logged in with my Facebook account and registering with my Twitter account too.
No, there is no global way of knowing I am the same person. The $response object sent me a unique ID for that specific user according to the provider policy. You might use this to identify already registered users and log them in.

Updating Meteor.users

I've created a form for users to update their profiles. When I submit the form I'm receiving a [403] error.
Not permitted. Untrusted code may only update documents by ID.
My question is, if I'm going to use Meteor.users.allow, where - in what file/directory - do I write this code?
Thanks,
Nathan
The error you're getting is not a result of your allow/deny rules. You would get a straight 'Access Denied' error if it were.
When updating your users (as well as having the correct allow rules in place) you need to update your user by their _id- especially if they are being updated on the client end.
So instead of
Meteor.users.update({name: "etc"}, {$set:..});
You need to split it in two, one to get the _id and then one to update your document on that.
var user = Meteor.users.findOne({name: 'etc'});
Meteor.users.update({_id: user._id}, {$set:..});
The rule is on the client you can only use _id to find the document when updating.

How to get resourceName for Tridion LocalizableMessage when creating new PublisherException?

I need to stop publishing of a page when a certain condition exists, for example if the page name contains 'one' using the Event System. Also, the other pages should continue to publish.
I am thinking to use a PublisherException instead of a generic exception.
The problem is the I do not know the resourceName of the LocalizableMessage. Any ideas?
if (item.Title.ToString().Contains("one"))
{
Localization.LocalizableMessage errResource = new Localization.LocalizableMessage("error");
throw new PublisherException(errResource, new Exception("Can't get there from here!"));
}
The Event System can stop Publishing, there is no middle ground there though, when you throw an exception, it stops the entire transaction.
Like Puntero mentions, if you want to remove an item from a Publish Transaction, that is where a Custom Resolver comes in. From here you cannot communicate back to the Publish Transaction, but you have access to the Tridion Logger (eventlog):
Tridion.Logging.Logger.Write("your message string", "MyResolver", LoggingCategory.General, TraceEventType.Information);
With regards to your LocalizableMessage in the Event System, you should be able to do the following:
throw new PublisherException(new LocalizableMessage(Properties.Resources.ResourceManager, "PagePublishErrorMessage"));
Where the resourceName is pointing to the name of a String resource you have in your Project.
I agree with #Puntero that if you want other page in a publish action to go through, you should use a Resolver rather than an Event Handler.
I tried to raise a warning to alert users of one item not being resolved, but failed. But there may be some good tips/ideas for you here: Raising a “warning” status during SDL Tridion 2011 publishing
In the end, the only way I could get anything to work was to set "Allow X failures", and then do a check in a template, and raise the error there. That will count as a Render failure, and allow the publisher to move on to the next item in the publish transaction.
As for the message? What message would you like to display?

how to send an activation code to the user in create user wizard?

I wanted to verify the user who is registering on My Website(using Create User Wizard ) by sending them a code on their E-Mail ID given at registration time...and they will have to use that code to activate his account.
could u please help me with this
Thanks
I found an article that walks through doing something very similarl. The only difference I see between the way they did it and what you are doing is that they included the code in a URL that the user just clicks and you want to have them type it in a box.
Link: http://www.aspcode.net/Requiring-email-verification-for-new-accounts.aspx
or https://web.archive.org/web/20211020153319/https://www.4guysfromrolla.com/articles/062508-1.aspx

Resources