I have one Joomla site and another web app which is ASP.NET MVC based. I am wishing to do auto login to another app after login to Joomla website.
For example is it possible that after a successful login in Joomla website, automatically issue a new request to this ASP based app with User ID and password ( encrypted of course ) embedded in query string. Then this ASP application would take that information and decrypt the password and perform auto login?
Here's How to use web services to share Joomla login session from one website to another? a example for one Joomla site with another Joomla site.
I hope to see code example for explain solution.
I'm not familiar with ASP .NET MVC, but you can intercept the Joomla login event by referring to Creating a Plugin for Joomla. It can be a very simple User Plugin, with which you will have access to many events, particularly OnUserLogin
and OnUserAfterLogin
. The code you put in either of those two events is where you'd use CURL, or whatever other technology, to POST your ASP request.
Very basic code structure:
<?php
defined('_JEXEC') or die;
class Plgtest extends JPlugin {
public function onUserLogin($user, $options = array()) {
// The user has now logged into Joomla - all user info is available in variable $user
// Do some PHP stuff here to "issue a new request to this ASP based app"
// Example PHP code for ASP login at https://stackoverflow.com/questions/25539787/how-to-post-asp-net-login-form-using-php-curl
}
}
?>
See this question for the PHP code to login to ASP from PHP.
I am not familiar with Joomla or ASP.NET, but I think the easiest way to do this is by storing the sessions in common place. This could be a database which both systems can access and read the session data from.
This solutions relies on the fact that one of the websites exists as a subdomain of the other or the cookie which the systems share cannot be read by both. Check this link for another solution working around this restriction. It is a messy solution, but possible.
Cookie restriction workaround (Stack Overflow)
As I said I don't know either frameworks, but I would imagine you would have to tinker with the way sessions are read/written to in both systems.
Hope this can help you in the right direction.
Best regards.