Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
29e24d1847
18 changed files with 235 additions and 106 deletions
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
|
||||
class AuthController extends Zend_Controller_Action
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function passwordRestoreAction()
|
||||
{
|
||||
//uses separate layout without a navigation.
|
||||
$this->_helper->layout->setLayout('bare');
|
||||
|
||||
$form = new Application_Form_PasswordRestore();
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->isPost() && $form->isValid($request->getPost())) {
|
||||
$user = CcSubjsQuery::create()
|
||||
->filterByDbEmail($form->email->getValue())
|
||||
->findOne();
|
||||
|
||||
if (!empty($user)) {
|
||||
$auth = new Application_Model_Auth();
|
||||
|
||||
$auth->sendPasswordRestoreLink($user, $this->view);
|
||||
$this->_helper->redirector('password-restore-after', 'auth');
|
||||
}
|
||||
else {
|
||||
$form->email->addError($this->view->translate("Given email not found."));
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function passwordRestoreAfterAction()
|
||||
{
|
||||
//uses separate layout without a navigation.
|
||||
$this->_helper->layout->setLayout('bare');
|
||||
}
|
||||
|
||||
public function passwordChangeAction()
|
||||
{
|
||||
//uses separate layout without a navigation.
|
||||
$this->_helper->layout->setLayout('bare');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$token = $request->getParam("token", false);
|
||||
$user_id = $request->getParam("user_id", 0);
|
||||
|
||||
$form = new Application_Form_PasswordChange();
|
||||
$auth = new Application_Model_Auth();
|
||||
$user = CcSubjsQuery::create()->findPK($user_id);
|
||||
|
||||
//check validity of token
|
||||
if (!$auth->checkToken($user_id, $token, 'password.restore')) {
|
||||
echo "token not valid";
|
||||
$this->_helper->redirector('index', 'login');
|
||||
}
|
||||
|
||||
if ($request->isPost() && $form->isValid($request->getPost())) {
|
||||
|
||||
$user->setDbPass(md5($form->password->getValue()));
|
||||
$user->save();
|
||||
|
||||
$auth->invalidateTokens($user, 'password.restore');
|
||||
|
||||
$zend_auth = Zend_Auth::getInstance();
|
||||
$zend_auth->clearIdentity();
|
||||
|
||||
$authAdapter = Application_Model_Auth::getAuthAdapter();
|
||||
$authAdapter->setIdentity($user->getDbLogin())
|
||||
->setCredential($form->password->getValue());
|
||||
|
||||
$result = $zend_auth->authenticate($authAdapter);
|
||||
|
||||
//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
|
||||
$authStorage = $zend_auth->getStorage();
|
||||
$authStorage->write($userInfo);
|
||||
|
||||
$this->_helper->redirector('index', 'showbuilder');
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
}
|
|
@ -12,9 +12,9 @@ class LoginController extends Zend_Controller_Action
|
|||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
if(Zend_Auth::getInstance()->hasIdentity())
|
||||
if (Zend_Auth::getInstance()->hasIdentity())
|
||||
{
|
||||
$this->_redirect('Nowplaying');
|
||||
$this->_redirect('Showbuilder');
|
||||
}
|
||||
|
||||
//uses separate layout without a navigation.
|
||||
|
@ -97,6 +97,87 @@ class LoginController extends Zend_Controller_Action
|
|||
Zend_Auth::getInstance()->clearIdentity();
|
||||
$this->_redirect('showbuilder/index');
|
||||
}
|
||||
|
||||
public function passwordRestoreAction()
|
||||
{
|
||||
//uses separate layout without a navigation.
|
||||
$this->_helper->layout->setLayout('login');
|
||||
|
||||
$form = new Application_Form_PasswordRestore();
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->isPost() && $form->isValid($request->getPost())) {
|
||||
$user = CcSubjsQuery::create()
|
||||
->filterByDbEmail($form->email->getValue())
|
||||
->findOne();
|
||||
|
||||
if (!empty($user)) {
|
||||
$auth = new Application_Model_Auth();
|
||||
|
||||
$auth->sendPasswordRestoreLink($user, $this->view);
|
||||
$this->_helper->redirector('password-restore-after', 'auth');
|
||||
}
|
||||
else {
|
||||
$form->email->addError($this->view->translate("Given email not found."));
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function passwordRestoreAfterAction()
|
||||
{
|
||||
//uses separate layout without a navigation.
|
||||
$this->_helper->layout->setLayout('login');
|
||||
}
|
||||
|
||||
public function passwordChangeAction()
|
||||
{
|
||||
//uses separate layout without a navigation.
|
||||
$this->_helper->layout->setLayout('login');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$token = $request->getParam("token", false);
|
||||
$user_id = $request->getParam("user_id", 0);
|
||||
|
||||
$form = new Application_Form_PasswordChange();
|
||||
$auth = new Application_Model_Auth();
|
||||
$user = CcSubjsQuery::create()->findPK($user_id);
|
||||
|
||||
//check validity of token
|
||||
if (!$auth->checkToken($user_id, $token, 'password.restore')) {
|
||||
echo "token not valid";
|
||||
$this->_helper->redirector('index', 'login');
|
||||
}
|
||||
|
||||
if ($request->isPost() && $form->isValid($request->getPost())) {
|
||||
|
||||
$user->setDbPass(md5($form->password->getValue()));
|
||||
$user->save();
|
||||
|
||||
$auth->invalidateTokens($user, 'password.restore');
|
||||
|
||||
$zend_auth = Zend_Auth::getInstance();
|
||||
$zend_auth->clearIdentity();
|
||||
|
||||
$authAdapter = Application_Model_Auth::getAuthAdapter();
|
||||
$authAdapter->setIdentity($user->getDbLogin())
|
||||
->setCredential($form->password->getValue());
|
||||
|
||||
$result = $zend_auth->authenticate($authAdapter);
|
||||
|
||||
//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
|
||||
$authStorage = $zend_auth->getStorage();
|
||||
$authStorage->write($userInfo);
|
||||
|
||||
$this->_helper->redirector('index', 'showbuilder');
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue