-
- 330 Posts
I am currently working on trying to integrate MODx webusers with Facebook connect, I currently have the system set up to authenticate the user via facebook connect, if this is the first time the user has logged in it then creates a user within MODx allocated to a specific group.
Now what I want to do is using a snippet log the user in, I can’t use weblogin or webloginpe (I think) since the user will not entering their password or username. All authentication is done on the facebook side all I want to do is once that authentication comes back show MODx that the user is logged in so that document groups / user groups reconise the fact.
So what I am saying is, is there some system variable/ cookie / db that I can update once the user is authenticated.
Hope that make sense.
-
- 1,010 Posts
As far as I know there’s nothing ready-made.
Have a look at weblogin.processor.inc.php in snippets/weblogin/ from about line 186. You’d need to more or less duplicate the code from there minus any $_POST handling and perhaps the events.
-
- 2,877 Posts
-
- 5,888 Posts
Try:
<?php
$user_id = $facebook->require_login();
// if statement dealing with account creation this all works
else
{
login($user_id);
return '<span class="important">'.$nlxAdded.'</span>';}
function login($user) {
# process login
global $modx;
$username = $modx->db->escape(strip_tags($user));
$givenPassword = $modx->db->escape($user.'appendextraprivatetopassword']);
//$captcha_code = isset($_POST['captcha_code'])? $_POST['captcha_code']: '';
//$rememberme = $_POST['rememberme'];
// invoke OnBeforeWebLogin event
$modx->invokeEvent("OnBeforeWebLogin",
array(
"username" => $username,
"userpassword" => $givenPassword,
"rememberme" => $rememberme
));
-
- 330 Posts
Thanks that got me past that problem now the next one. But that is something to do with the SQL statement taken stright from weblogin but not working havent got to look at it now so will come back to it.
-
- 1,010 Posts
Unless you are expecting plugins to work with your snippet and you provide code that acts on the return of these plugins in a consistent way (consistent with how weblogin handles them) there is no need to include the modx->invokeEvent() code in your snippet.