We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Login user to oxwall from external PHP (Home page) | Forum

Offir
Offir Feb 11 '13
Hi there,


I have a custom home page with a custom login/signup modal. I want to connect that to my oxwall setup so when the user logins on the homepage / modal he will be redirected to his profile (logged in) on my oxwall setup. I have been trying to look for the PHP code but cant seem to find it. 

Attachments:
  Screen Shot 2013-02-11 at 10.15.17 PM.png (26.37Kb)
Dean L
Dean L Feb 13 '13
if ( OW::getUser()->isAuthenticated() )
        {
            $this->redirect(OW::getRouter()->urlForRoute('base_member_profile'));
       }

This will redirect any logged in user to their profile page... Hope that helps.
Offir
Offir Mar 18 '13
Hey thanks for the reply. This is helpful but doesn't tell me HOW to authenticate the user. Is there a function that I can give OW a username and pw and it can authenticate the user?
Michael I.
Michael I. Mar 27 '13
Hi, you can authenticate a user only by user ID. Try playing with this function:


OW_User::getInstance()->login($userId);

nisha
nisha Sep 11 '13
Hi, I am very new in Oxwall. I want to login to oxwall site using login to other website.
My code is:

<?php
define('OW_URL_HOME', 'http://localhost/oxwall_new/index.php');
define('_OW_', true);

define('DS', DIRECTORY_SEPARATOR);

define('OW_DIR_ROOT', dirname(__FILE__) . DS);
require_once(OW_DIR_ROOT . 'ow_includes' . DS . 'init.php');
require_once(OW_DIR_ROOT . 'ow_system_plugins' . DS . 'base/classes/standard_auth.php');
require_once(OW_DIR_ROOT . 'ow_core' . DS . 'session.php');
$username = $_GET['username'];
$password = $_GET['password'];


$adapter = new BASE_CLASS_StandardAuth($username,$password);
$result = OW::getUser()->authenticate($adapter, true);
     
                if ( $result->isValid() )
                {
                    if ( isset($data['remember']) )
                    {
                        $loginCookie = $this->userService->saveLoginCookie(OW::getUser()->getId());
     
                        setcookie('ow_login', $loginCookie->getCookie(), (time() + 86400 * 7), '/', null, null, true);
                    }
           
                }
   
session_regenerate_id();     

header('Location:http://localhost/oxwall_new/index.php')
?>


Using this code i am redirecting to oxwall site when i login through other website. but not logged in to oxwall site. If i see in data base there is one table "ow_base_user_online" which shows an entry for on-line user.
i am unable to understand if i am not logged in how it can show this entry for user 1 & if it is showing entry in this table then why i am not logged in to oxwall site.
please help & let me know if doing anything wrong. Help would be appreciated. thanks in advance. waiting for reply

Daisy Team
Daisy Sep 19 '13
nisha, you should develop a new plugin using the following authentication string:

OW_Auth::getInstance()->login($userId);

You can check out the /ow_system_plugins/base/bol/user_dao.php file to see how it works.
Daisy Team
Daisy Sep 19 '13
Also, you can use the solution described in this topic: http://www.oxwall.org/forum/topic/13183