Re: Preventing error message on initial forceLogin
Dan Rossi <liveuser-zu2dZaOKXTSc5qR/[email protected]>
| Newsgroups | gmane.comp.php.pear.liveuser |
|---|---|
| Message-ID | <[email protected]> |
On 27/06/2005, at 11:02 PM, Lukas Smith wrote:
>>
>
> so you dont pass any handle to the init() method, but you do use the
> remember me feature?
>
> in that case .. can you open a bug report and give me a var_dump() of
> the returned $result from the readRememberCookie() method call in the
> login() method?
>
Heres how i setup the liveuser events class for the restricted area,
and then the class for the login script
forceLogin on the events class forces a logout which postLogout sends
to the login page. This is prob complety out of wack and bending the
rules , but i required the login script to be doing the posting, as i
cant post to the current script coz it may already have a post request
callback method already doing something else :\
class Feeds_Admin_LiveUser_Events extends Feeds_Admin_LiveUser {
function Feeds_Admin_LiveUser_Events()
{
parent::Feeds_Admin_LiveUser();
$this->liveuser =& LiveUser::factory($this->conf);
$this->liveuser->dispatcher-
>addObserver(array($this,'get'),null,'LiveUser');
$logout = (isset($_GET['logout'])) ? $_GET['logout'] : null;
$this->liveuser->init(null,null,$logout);
}
function get($notification)
{
if (method_exists($this,$notification->getNotificationName()))
call_user_func(array($this,$notification-
>getNotificationName()),$notification);
}
function postLogout()
{
HTTP::redirect('login.php');
}
function forceLogin(&$notification)
{
$this->liveuser->logout();
}
function messageHandler()
{
//return $this->liveuser->statusMessage($this->liveuser->status);
}
}
class Feeds_Admin_LiveUser_Login extends Feeds_Admin_LiveUser {
function Feeds_Admin_LiveUser_Login()
{
parent::Feeds_Admin_LiveUser();
$this->liveuser =& LiveUser::factory($this->conf);
$this->liveuser->dispatcher-
>addObserver(array($this,'get'),null,'LiveUser');
$username = (isset($_POST['username'])) ? $_POST['username'] : null;
$password = (isset($_POST['password'])) ? $_POST['password'] : null;
$remember = (isset($_POST['remember'])) ? $_POST['remember'] : null;
//$logout = (isset($_GET['logout'])) ? $_GET['logout'] : null;
$this->liveuser->init($username, $password, null, $remember);
}
function get($notification)
{
ob_start();
if (method_exists($this,$notification->getNotificationName()))
call_user_func(array($this,$notification-
>getNotificationName()),$notification);
ob_end_clean();
}
function onUnfreeze($notification)
{
HTTP::redirect('index.php');
}
function onLogin()
{
$this->do = DB_DataObject::factory('users_join');
$_SESSION['customerID'] =
$this->do->getCustomerID($_SESSION['ludata']['perm']['permUserId']);
HTTP::redirect('index.php');
}
function onFailedLogin($notification)
{
//die("yes");
//$this->liveuser = $notification->getNotificationObject();
}
function forceLogin(&$notification)
{
$form = new HTML_QuickForm();
$form->addElement('text','username','Username');
$form->addElement('password','password','Password');
$form->addElement('checkbox','remember','Remember Login?');
$form->addElement('submit','login','Login');
$renderer =& new HTML_QuickForm_Renderer_Object(true);
$form->accept($renderer);
$this->form = $renderer->toObject();
$this->tpl->compile('login_main.html');
$this->tpl->outputObject($this);
exit;
}
function messageHandler()
{
//return $this->liveuser->statusMessage($this->liveuser->status);
}
}