I'm trying to create an SSO login for a couple of modx sites using the hybridAuth library and authenticate against google, facebook, linkedin etc. Got the library working and authenticating users fine and passing info back to my modx instance just fine. But now I'm running into issues creating sessions for the user, consider this:
// this gets the modx user by email address from the returned social profile
$modx_user = get_modx_user_from_email($modx, $social_profile);
// create a user object from the internal key [added to the social profile earlier]
$user = $modx->getObject('modUser', $modx_user['internalKey']);
// this seems to give the user a session, but no permissions to do anything.
$user -> addSessionContext('web');
// if the user successfully authenticates against google, this will return "is authenticated"
if (!$modx->user->isAuthenticated('web')) {
echo 'not authenticated';
}else{
echo 'is authenticated';
}
This works up to a point, it seems to create a session for the user & cookies in the browser, but the user has no permissions, this:
[[+modx.user.id]]
[[+modx.user.username]]
will return 0 (anonymous)
so it ~seems~ like the user is authenticated, but can;t do anything. What is the next step here to get the user able to interact with the site??
Keep in mind, that I do not have a username or password so I can't pass them to the actual login processor. There is however an interesting looking line in the login script,
$modx->invokeEvent("OnWebLogin", $postLoginAttributes);
is there something in the OnWebLogin event that is setting the user permissions?