simple form for adding a user to the database, only available for admin users.
This commit is contained in:
parent
2830137d23
commit
1fc21819cc
30 changed files with 445 additions and 222 deletions
|
@ -30,25 +30,23 @@ class LoginController extends Zend_Controller_Action
|
|||
|
||||
$authAdapter = $this->getAuthAdapter();
|
||||
|
||||
# get the username and password from the form
|
||||
//get the username and password from the form
|
||||
$username = $form->getValue('username');
|
||||
$password = $form->getValue('password');
|
||||
|
||||
# pass to the adapter the submitted username and password
|
||||
//pass to the adapter the submitted username and password
|
||||
$authAdapter->setIdentity($username)
|
||||
->setCredential($password);
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
|
||||
# is the user a valid one?
|
||||
if($result->isValid())
|
||||
{
|
||||
# all info about this user from the login table
|
||||
# omit only the password, we don't need that
|
||||
//all info about this user from the login table omit only the password
|
||||
$userInfo = $authAdapter->getResultRowObject(null, 'password');
|
||||
|
||||
# the default storage is a session with namespace Zend_Auth
|
||||
//the default storage is a session with namespace Zend_Auth
|
||||
$authStorage = $auth->getStorage();
|
||||
$authStorage->write($userInfo);
|
||||
|
||||
|
|
36
application/controllers/UserController.php
Normal file
36
application/controllers/UserController.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
class UserController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/* Initialize action controller here */
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// action body
|
||||
}
|
||||
|
||||
public function addUserAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_AddUser();
|
||||
|
||||
if ($request->isPost()) {
|
||||
if ($form->isValid($request->getPost())) {
|
||||
|
||||
$formdata = $form->getValues();
|
||||
User::addUser($formdata);
|
||||
$form->reset();
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -116,7 +116,9 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
|
|||
else {
|
||||
$this->_roleName = "guest";
|
||||
}
|
||||
|
||||
|
||||
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName);
|
||||
|
||||
$resourceName = '';
|
||||
|
||||
if ($request->getModuleName() != 'default') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue