Commit 5971e6fa authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

pass hash : become user different for patrons and others

parent f86f9533
......@@ -161,23 +161,35 @@ class Admin_IndexController extends ZendAfi_Controller_Action {
public function becomeAction() {
if(!Class_Users::getIdentity()->isSuperAdmin()) {
if (!Class_Users::getIdentity()->isSuperAdmin()) {
$this->_helper->notify($this->_('Vous n\'avez pas les droits suffisants pour utiliser cette fonctionnalité.'));
return $this->_redirectToIndex();
}
if(!$user = Class_Users::find($this->_getParam('id', null))) {
if (!$user = Class_Users::find($this->_getParam('id', null))) {
$this->_helper->notify($this->_('Utilisateur invalide'));
return $this->_redirectToIndex();
}
if(!ZendAfi_Auth::getInstance()->authenticateLoginPassword($user->getLogin(), $user->getPassword())) {
if ($user->isAbonne())
return $this->_becomePatron($user);
ZendAfi_Auth::getInstance()->logUser($user);
$this->_helper->notify($this->_('Vous êtes maintenant connecté avec l\'utilisateur "%s"',
$user->getNomComplet()));
$this->_redirectToIndex();
}
protected function _becomePatron($user) {
if (!ZendAfi_Auth::getInstance()->authenticateLoginPassword($user->getLogin(), $user->getPassword())) {
$this->_helper->notify($this->_('Nom d\'utilisateur ou mot de passe invalide'));
return $this->_redirectToIndex();
}
$this->_helper->notify($this->_('Vous êtes maintenant connecté avec l\'utilisateur "%s"',
$user->getNomComplet()));
$this->_redirectToIndex();
return $this->_redirectToIndex();
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment