I have tried the plugin at
http://bobsguides.com/blog.html/2016/04/06/bypassing-the-modx-manager-login-i/ as suggested by Bob. It is generally successful but am getting some weird results.
I have put together some code for the element lgnLoginTpl which successfully logs in a Modx user as well as logging in to a remote site using the same credentials.
Code I am using is as below. I'm not an expert so it is probably untidy and can be refined, but it works. I am able to access the other site succesfully using an iframe on another Modx page. Credentials entered into the first form are duplicated into the second form using 'onblur' and then both forms are submitted by the script.
However, I have a couple of problems.
1. When a user who is not in the Modx database (but is in the remote server database) tries to access, the plugin doesn't fire and create a new user in Modx as I expect it should. It does however work if I am logged into the manager as admin in the same browser in a separate Tab , so I am assuming that it is some sort of permissions problem for anonymous user?
2. When a user logs in, the page is not refreshed which means that the form remains and the logout link does not appear in its place.
3. Error messages do not show.
Any ideas from those more skilled than me would be appreciated.
<script>
$(document).ready(function() {
$("#myLogin").click(function() {
$.post($("#Login").attr("action"), $("#Login").serialize(),
function(data) {
$("#msg").append(data);
$.post($("#myclubLogin").attr("action"), $("#myclubLogin").serialize(),
function(data) {
$("#msg").append(data);
});
});
});
});
</script>
<div class="loginMessage">[[+errors]]</div>
<form id="Login" name="Login" class="loginLoginForm" action="[[~[[*id]]]]" method="post" >
<fieldset class="loginLoginFieldset">
<!-- Show Member Login message --> <legend class="loginLegend"></legend>
<label class="loginPasswordLabel" style="color: #AEE67A;"> Username:
<input class="loginUsername" type="txt" name="username" onblur="document.myclubLogin.user.value = this.value;" />
</label>
<label class="loginPasswordLabel" style="color: #AEE67A;"> Password:
<input type="password" name="password" onblur="document.myclubLogin.password.value = this.value;"/>
</label>
<input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]" />
[[+login.recaptcha_html]]
<input class="loginLoginValue" type="hidden" name="service" value="login" />
</fieldset>
</form>
<div class="loginMessage">[[+errors]]</div>
<form name="myclubLogin" id="myclubLogin" method="post" action="url_to_log_in_to_remote_server" target="myClub">
<fieldset class="loginLoginFieldset" >
<input id="action" type="hidden" name="action" value="login" />
<input class="loginUsername" type="hidden" name="user" id="user" />
<input type="hidden" name="password" />
<input id="action" type="hidden" name="action" value="password" />
<input class="loginLoginValue" type="hidden" name="service" value="login" />
<span class="loginLoginButton">
<input id="myLogin" name="myLogin" type="submit" value="[[+actionMsg]]" style="float: right;"/>
</span>
</fieldset>
</form>
<div>
<iframe id="myClub" name="myClub" style="width:0; height:0; border:0; border: none;"></iframe>
</div>
[ed. note: bobd72 last edited this post 9 years, 10 months ago.]