We are in the process of building a user synchronization plugin for Joomla 2.5 (gets Joomla users and sends them to another platform via a JSON API call). This all works fine, however once copied, the updates on the profiles in Joomla don't get reflected to the external platform.
I see that there are some events such as onUserAfterSave and onUserBeforeSave, but as far as I understand, these are only available for plugins and not for components (we are building a component with frontend and backend).
So my question is, how do we detect programmatically that the user has changed his profile somehow (name, email or password) and execute something in our component accordingly.
You need to create a user profile plugin. You can pack the plugin together with your component in a package when distributing it. It is quite common in Joomla to have extensions contain 1-2 components, a module and a plugin. This is how Joomla separates specific jobs in specific extensions.
Good examples on how to do it are already inside here:
/plugins/user/
Here is your method signature:
/**
* #param array $user Holds the new user data.
* #param boolean $isnew True if a new user is stored.
* #param boolean $success True if user was succesfully stored in the database.
* #param string $msg Message.
*/
public function onUserAfterSave($user, $isnew, $success, $msg)
{}
Basically inside the method you can do whatever you want, in your case probably updating some tables from your component.
Related
With the upgrade to Magento 2.4.5 from 2.4.2, the old code in an observer class in the custom module to get information about Stripe Payment isn't working any more. It looks like Magento event sales_order_place_after isn't able to help with retrieving payment information. I tried several other events including sales_order_load_after sales_order_save_before sales_order_save_after sales_order_delete_before sales_order_delete_after checkout_submit_all_after. Below is the code snippet that calls a function by passing a Stripe payment object and an array containing order details. $stripePayment->getCard() returns null although Magento admin shows all payment information.
switch ($_payment_info->getMethod()) {
case "stripe_payments":
// We need to set the current_order in registry, as StripeIntegration script info.php uses this registry.
// Instantiate the StripeIntegration Info class after setting the registry.
$this->registry->register('current_order', $order);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$stripePayment = $objectManager->get('StripeIntegration\Payments\Block\Adminhtml\Payment\Info');
// Now, we can make the calls to retrieve the Stripe details for the Credit card.
$this->get_credit_card_payment_info($order_info, $stripePayment->getCard());
$order_info["cc_name"] = $order->getBillingAddress()->getName();
$order_info["cc_veri"] = $order->getPayment()->getTransactionId();
break;
The comments in it will help you understand that I'm using registry to store the order object for the Stripe module to use in its class. This has been working fine for the past three years until the latest Magento upgrade.
We are creating webevents in a DB other than Kentico. These webevents are then used for enterprise reporting. I need to implement the same inside Kentico project.
Is there an event that can fire after the page has loaded so that i can create my web event with page name and user information if logged in.
I have also seen in the past that with events, the Request and Session objects are not available. However, HTTPContext.Current is available. I need the Request and Session objects.
We are using Kentico version 7.0.92 and have a portal template site.
Now, i don't want to use portal template page to create events since this code executes multiple times with each request for a page.
Basically, i am interested in the PageName, Session and Request objects.
I have looked around Kentico 7 documentation. Looks like we have CMSRequestEvents but haven't been able to find sample code.
Update:
Looks like the missing piece is CMSContext class. Now just trying to find the right event for CMSRequestEvents, where i have the Session object available.
I'd suggest modifying Kentico\CMS\Global.asax.cs in the following way:
public override void Init()
{
base.Init();
CMSRequestEvents.AcquireRequestState.After += AcquireRequestState_After;
}
void AcquireRequestState_After(object sender, EventArgs e)
{
// Do your stuff...
}
By that time the HttpContext.Current.Session should already be initialized. Page name can be retrieved from the HttpContext.Current.Request which should never be null.
Still using a very old (and slightly customized) version of BlogEngine.NET on a Windows XP (!) server so I'm a bit afraid to upgrade.
In the past, I have written a couple of extensions in order to grant or prevent access to static pages and/or posts based upon the users / roles and / or the post categories. For instance, I can prevent access to the blog from unauthenticated users, I can grant access to a subset of the blog (post categories) to users having the 'Readers' role, etc.
I noticed that images are still accessible, either ones stored explicitly under the /App_Data/files/ folder and served by the image.axd handler, or ones associated with blog posts.
Is there an extension point available where I could add some logic to prevent access to images based on criteria such as authentication and/or users / roles ? Perhaps based upon their file extensions, or whatnot ?
I don't know about an official extension point but I think the edits you need to make are as follows.
According to this line in the web.config
<add verb="*" path="image.axd" type="BlogEngine.Core.Web.HttpHandlers.ImageHandler, BlogEngine.Core" validate="false"/>
The image.axd is handled by BlogEngine.Core.Web.HttpHandlers.ImageHandler
If you look in the BlogEngine.Core project you will find the ImageHandler.cs that defines this class. Assuming you need access to the Session you will need to IReadOnlySessionState as an implemented interface to the class.
public class ImageHandler : IHttpHandler, IReadOnlySessionState {
...
}
Once this is in place you can access the Session in the ProcessRequest Method to perform your custom checks.
public void ProcessRequest(HttpContext context) {
if(context.Session["SomeKey"] == true){
//serve image code goes here
}
}
There are questions about getting the profile image from Twitter, Facebook or Google, but it would be nice if there were a simple and extensible wrapper that returned the profile image regardless of the current user's account service.
I think you would want to set the users profile picture yourself. Because the services do not have a standard way to store profile picture. And the meteor oauth has no required code for each service class to implement.
You could set it on account creation. This would require writing code for each service.
Accounts.onCreateUser(function (options, user) {
if (user.services.google !== undefined) {
user.profile.profile_picture = user.services.google.picture;
}
if (user.services.twitter !== undefined) {
user.twitter.profile_picture = user.services.twitter.profile_url; // sudo param name
}
return user;
})
or on publish.
In the meantime there is an Atmosphere package that returns the user profile picture and works for a lot of auth services:
bengott:avatar
Instead of bengott:avatar (which is now deprecated), use the utilities:avatar package instead
You might also want to look at the accounts-meld package.
I have an MVC3 app for which I want to implement claims support. My goal is as follows:
provide a SignIn link, which when clicked displays a popup window with username/password and Facebook/WindowsLive/Google etc. links
automatically redirect to my SignIn page when a protected controller is accessed e.g. /Order/Delete
I've set up the application and providers in AppFabricLabs.com and included the STS in my project. I've also created an implementation of IAuthorizationFilter so I can mark my controllers as [WifAuth] and successfully get the OnAuthorization method called. I've implemented the use-case where the visitor has not been authenticated like this:
private static void AuthenticateUser(AuthorizationContext context)
{
var fam = FederatedAuthentication.WSFederationAuthenticationModule;
var signIn = new SignInRequestMessage(new Uri(fam.Issuer), fam.Realm);
context.Result = new RedirectResult(signIn.WriteQueryString());
}
and successfully get AppFabricLabs page with my Identity Provider choices (haven't figured out how to customise that page). When I log in my returnUrl gets called so I land in a controller method /Home/FederationResult, however the form posted to me contains only wa and wresult fields but I need wctx to know where to send the user... I haven't been able to figure out why.
the wresult is an XML document that contains (amongst a bzillion other things) the name and e-mail address of the user logging in but sadly does not contain the url to which the user was headed.
have I failed to configure something or am I just off base? thoughts anyone?
e
Just specify a Context for the SignInRequestMessage:
signIn.Context = HttpContext.Current.Request.RawUrl;
The wctx parameter is included in every request/response and also part of the form posted finally to your site.