calling twigswiftmailer inside Guard Authenticator in symfony 2 - twig

i am using guard as my custom authenticator, i need to send an email inside the authenticator, using the service fos_user.mailer that i injected which has arguments amoung which there is twig because it renders the message it needs to send, now the problem i have is that i get an error "Circular reference detected for service ..." which says that my authenticator calls the mailer which calls the twig which again calls the authorization checker (my authenticator) resulting in an endless loop,
do you have any solutions for this

The quick and dirty workaround is to inject the container to your authenticator and get the mailer service when you need it. It's dirty, because it hides your dependencies.
But why do you need to send an email in your authenticator? Can you use one of symfony's authentication-related events instead? (See the AuthenticationEvents and SecurityEvents classes). If that's not enough, you can also create your own event and listen to that in a different service, that's responsible for sending that mail.

Related

Slack: Bot name in sent messages

I created a bot named "esmeralda". When I send a message to Slack with the token generated for this esmeralda, the message just appears to be from "bot", not "esmeralda".
Can I do something so that the message will be shown to be sent by "esmeralda" instead the "bot"?
I'm guessing you're using the Web API and therefore the chat.postMessage method?
I'm further guessing that you're not passing as_user=true as one of your parameters. Try doing that.
(If my guesses are wrong, please include the actual details of what you're doing: at least tell us what API you're using, what method you're calling, and what parameters you're passing. Ideally share code.)

Using the browser client, how can I set the sounds.disconnect() on every call?

Using the browser client, how can I set the sounds.disconnect() on every call? Is there a way to access the device singleton to modify that setting? I know I can access when I get the device.ready callback, but I want to modify the setting on every call.
I received a helpful reply back from Twilio support:
--
That parameter will be instantiated in Twilio.Device either True or False once the web page loads, so to change it, I believe you would necessarily need to also reload the page.
This would create another control layer in effect, that isn't provided out of the box by Twilio: you'd need to build a web page to change the variable that determines sounds.outgoing(), and then trigger the page to reload.
Another option would be simply create a second Client instance running on a separate tab, and have both instances use the same outbound caller ID. That might be easier.
--
In my scenario I'll need to find a different approach, and will look in to disabling the Twilio sounds and using my own.

Having problems with creating a DocuSign Connect Listener

I'm fairly new to DocuSign Connect and I'm trying to code a listener for data updates coming from the service using CodeIgniter. Currently, I'm trying to insert any post variables sent to CodeIgniter in the hopes of studying the data that's actually being passed, but I've been unsuccessful. Here's the part of the code that I have:
public function receive()
{
$post = $_POST;
$post = serialize($post);
$results = $this->db->query("insert into capture (`key`,`capturedXML`) values ('temp','".$post."')");
}
The problem is that nothing comes out of it, or is empty. I know that information is passed via POST, so I'm not sure what I'm doing wrong.
A couple of suggestions:
Instead of coding a listener application from scratch, consider
leveraging one of the listener applications that DocuSign has published to GitHub:
https://github.com/docusign/DocuSign-eSignature-SDK. Each
language-specific folder (Java, .NET, PHP, etc.) contains a
Connect folder that you should be able to utilize as a basis for building your listener.
Be sure to ensure that DocuSign Connect is successfully delivering messages to
the endpoint that you've specified for your listener. You can do
this by enabling the Log in your Connect configuration settings
(via the DocuSign UI, select "Enable Log" checkbox for the Connect
Configuration) -- then triggering an envelope event for which your
Connect configuration is set to send a notification (example: Send
an Envelope) -- then checking the log message in DocuSign
(Preferences >> Connect >> Logs). The log entry that's
generated when the envelope event occurs should indicate success, if
the message reached the endpoint.
Finally, if you haven't already, check out the DocuSign Connect Service Guide for info about how Connect works, etc.: http://www.docusign.com/sites/default/files/DocuSign_Connect_Service_Guide.pdf.

Adding a user to a list with mandrill

I'm trying to create a simple page on heroku to gather emails for an upcoming product launch. I'm trying to use the nodejs mandrill api wrapper to do accomplish this but it looks like there's no method for adding a user to a list. List subscription seems like it would be a really basic ESP function, am I missing something or is there some reason why this isn't included in the api.
Mandrill doesn't store your subscribers (unlike mailchimp), only your recipients blacklisted. You have to build your own storage layer.

Communicating between IFRAME and an entity

I couldn't make a request to a remote server using JavaScript in the onload function due to access is denied insanity. So, just to make CRM obey, I set up an IFRAME and connect that to a HTML page running my JavaScript. Now, provided that I get some values inside the script (run in an IFRAME) how can I communicate them to a method in the holding parent?
Not quite sure how to explain it more detailed so please feel free to ask.
The access is denied is the Same Origin Policy. You're going to run into the same problem from the IFRAME unless you're serving the page or just the script src from the same server you're subsequently trying to make the AJAX request to.
Assuming you are doing the latter then you just need to make sure you have unchecked the "Restrict cross-frame scripting" option on the IFRAME you added to the CRM form. From the IFRAME you will now have access to your function that you've defined at global scope on the parent CRM form via window.parent.yourfunctionNameHere(xyz).
postMessage sounds like it might fit.
window.postMessage, when called, causes a MessageEvent to be dispatched at the target window when any pending script that must be executed completes (e.g. remaining event handlers if window.postMessage is called from an event handler, previously-set pending timeouts, etc.). The MessageEvent has the type message, a data property which is set to the string value of the first argument provided to window.postMessage, an origin property corresponding to the origin of the main document in the window calling window.postMessage at the time window.postMessage was called, and a source property which is the window from which window.postMessage is called.
To use window.postMessage, an event listener must be attached:
// Internet Explorer
window.attachEvent('onmessage',receiveMessage);
// Opera/Mozilla/Webkit
window.addEventListener("message", receiveMessage, false);
And a receiveMessage function must be declared:
function receiveMessage(event) {
// do something with event.data;
}
The off-site iframe must also send events properly via postMessage:
<script>window.parent.postMessage('foo','*')</script>
Any window may access this method on any other window, at any time, regardless of the location of the document in the window, to send it a message. Consequently, any event listener used to receive messages must first check the identity of the sender of the message, using the origin and possibly source properties. This cannot be understated: Failure to check the origin and possibly source properties enables cross-site scripting attacks.
Source: https://developer.mozilla.org/en/DOM/window.postMessage
Recently I had the joy of connecting to a web service and retrieve some data. When that’s been achieved, I found myself sitting on the said data not exactly knowing where to put it.
To make the long story short, I used the following source code.
parent.window.Xrm.Page.data.entity.attributes
.get("new_Konrad").setValue("Viltersten");
Notable is the fact that in order to communicate with the parent form, the HTML file (where my JavaScript resided), needed to be placed as a web resource within the CRM structure. By other words, just by pointing to an external “http://some.where/some.thing” we can consume a service but won’t be able to convey the obtained information up the CRM server, at least not when developing a solution for the on-line version.

Resources