Looking for a simple example

Cetra3

Joined: 2006-08-13
Posts: 3
Posted: Mon, 2007-11-19 11:53

Hello.

I'm having trouble reverse engineering the API to understand the login system that you need to embed the api with.

Basically I've been digging for a simple login script example. It'd look something like this:

if (user_logged_in()) {

  level = check_level();
  
   if(level==admin) {
    
       do_something();
     
   }


} elseif(submitting_form) {


 check_post_data

   if(check_post_data) {

     login
  
   }


} else {


 show_login_page

}

I have a basic script that calls

GalleryEmbed::init

and then

GalleryEmbed::handleRequest

But in between I'm not really sure what component of the API I need to send gallery the username and password. I also cant find out how to attain that they're admin or just a normal user.

The basis for this is i want to create a seperate admin page for my CMS but use gallery2 for my user sessions and authentication as there will need to be heaps of admin related things to do with gallery2.

I have had a look at a few pages in the wiki section and the API reference but there isn't any info on sending username and password information to gallery.

Hope you guys can help.

Thanks

 
Slayergirl
Slayergirl's picture

Joined: 2007-09-12
Posts: 180
Posted: Mon, 2007-11-19 14:19

Embed does not check password. It just check if there's is a username in the externalmapped table (not user table!)

What you can do is use the Embed anyway to check if a user is already loggedin (as far as I know it needs to be in the Gallery-dir...else you will prob end up with cookie problems ) This is something I worked on & I found with info from Valiant.

Quote:
//path to your embed.php
include('embed.php');

function checkLogin(){
$ret = GalleryEmbed::init(array('fullInit' => true));

if ($ret) die('an error occurred');
global $gallery;
//check if user is already loggedin (cookie)
list ($ret, $isGuest) = GalleryCoreApi::isAnonymousUser();
if ($ret) die('an error occurred');
if ($isGuest) {
//show login block use the existing info from the Gallery form (view it in source in your browser) digging around didn't get me any futher.
}else{
//user already loggedin do nothing or print username something like that
}