Question

I have my existing web application in which user can register/logged in and access their details. Now I want to integrate elgg with my application.

When user logged into my system then there will be menu available like "elgg", when user click on that than they can see community of elgg, but no need to login to that.

They can be authenticate by my existing application.

Please help me out.

Was it helpful?

Solution

You can get username and password of user's and use following code to directly authenticate in ELGG and use it's functionality.

//now authenticate user if not logged in
if(true===elgg_authenticate($SESSION['username'], $token_password)) {

    $user = get_user_by_username($SESSION['username']);

    try {
         login($user, $persistent = false);
         system_message(elgg_echo('loginok'));

         //if admin then redirect to administration
         if(elgg_is_admin_logged_in()) {
              forward('admin');
         } else {
              forward('dashboard');
         }
    }catch (LoginException $e) {
         register_error($e->getMessage());
         //forward(REFERER);
    }
}

OTHER TIPS

You can write your custom PAM handler for Elgg, that would handle the integration. See: http://docs.elgg.org/wiki/Engine/Authentication

Apart from that, you probably want to keep the accounts in sync. Have a look at create/update/delete user events.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top