Small fixes to user model + Form decorators
This commit is contained in:
parent
359e42a44b
commit
49ecfc9fbd
7 changed files with 33 additions and 16 deletions
|
|
@ -77,7 +77,7 @@ class Mapper_User extends Fiktiv_Model_Mapper_DbTableAbstract
|
|||
$auth = Zend_Auth::getInstance();
|
||||
|
||||
// Setup auth adapter
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($this->getAdapter(), $this->_name, 'email', 'password');
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($this->_dbTable->getAdapter(), $this->_dbTable->_name, 'email', 'password');
|
||||
|
||||
// Set credentials
|
||||
$authAdapter->setIdentity($email);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
class Table_User extends Zend_Db_Table_Abstract
|
||||
class Table_User extends Fiktiv_Db_Table_Abstract
|
||||
{
|
||||
protected $_schema = 'fiktivkod';
|
||||
protected $_name = 'User';
|
||||
protected $_primary = 'id';
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -42,28 +42,17 @@ class AuthController extends Fiktiv_Controller_Action
|
|||
|
||||
if ($this->_request->isPost() && $form->isValid($this->_request->getParams())) {
|
||||
|
||||
$users = new Users();
|
||||
$users = $this->dataService->User;
|
||||
|
||||
if ($users->login($this->_request->getParam('email'), $this->_request->getParam('password'))) {
|
||||
|
||||
// TODO: redirect user
|
||||
$this->_redirect('/');
|
||||
} else {
|
||||
// TODO: Wrong email / password
|
||||
var_dump($emailElement->getErrors());
|
||||
echo "Wrong email / password";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "You are ";
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if ($auth->hasIdentity()) {
|
||||
$user = $auth->getIdentity();
|
||||
echo $user->firstName;
|
||||
} else {
|
||||
echo "Nobody";
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
|
||||
}
|
||||
|
|
|
|||
10
library/Fiktiv/Db/Table/Abstract.php
Normal file
10
library/Fiktiv/Db/Table/Abstract.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
class Fiktiv_Db_Table_Abstract extends Zend_Db_Table_Abstract
|
||||
{
|
||||
public function __get($name)
|
||||
{
|
||||
if ('_name' === $name)
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
6
library/Fiktiv/Form.php
Normal file
6
library/Fiktiv/Form.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Fiktiv_Form extends Zend_Form
|
||||
{
|
||||
|
||||
}
|
||||
6
library/Fiktiv/Form/Decorator/Abstract.php
Normal file
6
library/Fiktiv/Form/Decorator/Abstract.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
abstract class Fiktiv_Form_Decorator_Abstract extends Zend_Form_Decorator_Abstract
|
||||
{
|
||||
|
||||
}
|
||||
6
library/Fiktiv/Form/Decorator/Standard.php
Normal file
6
library/Fiktiv/Form/Decorator/Standard.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Fiktiv_Form_Decorator_Standard extends Fiktiv_Form_Decorator_Abstract
|
||||
{
|
||||
|
||||
}
|
||||
Reference in a new issue