I really wouldn't call what I'm doing 'embedding' so I don't know if I have to use the empedding API or not; I was hoping someone could enlighten me. Here is my situation: Gallery2 has a completely standalone copy with its own users. I have an non-gallery page that I would like to make into a single-signon for all the relevant services (g2 being one of them).
Given I have the user's USERNAME, how can I lookup the Gallery2 account and setup the session so when I navigate to the Gallery2 pages, it's as if they logged in via the gallery page. Below is what I'm using to create a user from my single-register for user registration. I was hoping I could make something similar for single-signon.
//
// Add User To Gallery
//
$username = $values['username'];
$fullname = $values['firstname'] . " " . $values['lastname'];
$email = $values['email'];
$password = $values['password'];
include('./gallery/bootstrap.inc');
include('./gallery/init.inc');
$ret = GalleryInitFirstPass();
$ret = GalleryInitSecondPass();
GalleryCoreApi::loadPlugin('module', 'core', true);
$GalleryUser = new GalleryUser();
$GalleryUser->create($username);
$GalleryUser->setemail($email);
$GalleryUser->setfullName($fullname);
$GalleryUser->changePassword($password);
$GalleryUser->save();
Any ideas?
Thanks,
- Bryan
Posts: 32509
GalleryEmbed is our solution to single-sign on.
please use GalleryEmbed.
see: docs/EMBEDDING, sticky embedding and integration topic, existing integrations (wpg2, mambo, drupal, xaraya, ..) as examples.
Posts: 6
Yeah, I've been doing that. Anyone have any idea why the following doesn't work? I go straight to the page and see 'Initialization Complete' -- no errors. Then I go to the main gallery page and I'm not logged in.
Posts: 6
Ugh, I must have copied/paste code from too many places. Needed to make g2_User->uid g2_User->getId(); and had to add GalleryEmbed::login();
Working now. Thanks
Posts: 32509
nope, still too much unneeded code.
- instead of include_once use require_once, this has built in error handling and will error out if embed.php isn't around.
- GalleryInitFirstPass isn't required, GalleryEmbed::init takes care of that. use fullInit => true in the ::init call.
- GalleryCoreApi::loadPlugin not needed
- 'activeUserId' => $g2_user->uid, isn't the way it's supposed to work
let's get back to your issue, maybe i misunderstood you:
usually, the term single-sign-on is used if you have multiple scripts / applications and you want to use a single login for them. such that when you're logged into application A, you're also logged into the other application(s).
is G2 the only application on your website with user management / login?
do you just want to add a login box on your other page? then you just have to copy the login form html to your other page and set the cookie path in site admin -> general to /