Re: Login script and posting

Dan Rossi <liveuser-zu2dZaOKXTSc5qR/[email protected]>
Newsgroups gmane.comp.php.pear.liveuser
Message-ID <[email protected]>
On 21/06/2005, at 2:41 AM, Lukas Smith wrote:

> Dan Rossi wrote:
>> Hey there, I have a little app framework, where I seperate get and  
>> post requests into methods for the page. I've run into an issue where  
>> I have the login form within the event dispatcher class posting where  
>> its logged out of the script, therefore posting into the script and  
>> firing the post method.
>> I was wondering if there was a way if I login to a login script and I  
>> use the onLogin method to redirect to antoher page. However what if I  
>> the pages is forced back to the login script, which event method is  
>> fired, as I'd want to bring it back to the login form somehow :\
>
> not sure what you mean .. the easiest thing for you is to just look at  
> LiveUser.php and search for the "$this->dispatcher->post()" calls.  
> that way you will see where all the events are fired.
>
>

i'm gonna post it again then :)

Here is my event dispatcher class, i may need to try and find the  
method which is used  when catching someone has not logged in and  
forcing them to login, but before forcelogin, as that is what i used  
for the login form :) I could use forcelogin as a method to redirect to  
the actual login form ??

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, $logout, $remember);
	}
	
	function get($notification)
	{
		//echo $notification->getNotificationName();
		$this->{$notification->getNotificationName()}($notification);
	}
	
	function onUnfreeze()
	{
		
	}
	
	function postLogout()
	{
		//die("yes");
	}
	
	
	function onIdled()
	{
		die("yes");	
	}
	
	function onLogout()
	{
		//die("logout");	
	}
	
	function onLogin()
	{	


		if (!isset($_SESSION['customerID'])) {
			$this->do = DB_DataObject::factory('users_join');
			$_SESSION['customerID'] =  
$this->do->getCustomerID($_SESSION['ludate']['admin']['authUserId']);
			
		
		}
	}
	
	function onFailedLogin($notification)
	{
		die("yes");
		//$this->liveuser = $notification->getNotificationObject();
	}
	
	function forceLogin(&$notification)
     {
		$this->users = DB_DataObject::factory('users');
		
		$array = array(
					   'fieldsToRender' => array('username','password'),
					   'excludeFromAutoRules'=>'__ALL__',
					   'submitText'=>'Login'
						);
		$fb = &DB_DataObject_FormBuilder::create($this->users,$array);
	
		
		$form = $fb->getForm($_SERVER['PHP_SELF']);
		
		$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);
     }

	
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.