first commit
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
/**
|
||||
* SOTESHOP/stUser
|
||||
*
|
||||
* Ten plik należy do aplikacji stUser opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stUser
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: loginUserValidator.class.php 617 2009-04-09 13:02:31Z michal $
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package stUser
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stLoginUserValidator extends sfValidator
|
||||
{
|
||||
public function initialize($context, $parameters = null)
|
||||
{
|
||||
// initialize parent
|
||||
parent::initialize($context);
|
||||
|
||||
// set defaults
|
||||
$this->getParameterHolder()->set('username_error', 'Zły login lub hasło.');
|
||||
$this->getParameterHolder()->set('password_error', 'Zły login lub hasło.');
|
||||
$this->getParameterHolder()->set('password_field', 'password');
|
||||
$this->getParameterHolder()->set('remember_field', 'remember');
|
||||
$this->getParameterHolder()->set('permision_error', 'Nie masz odpowiednich uprawnień');
|
||||
|
||||
|
||||
$this->getParameterHolder()->add($parameters);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function execute(&$value, &$error)
|
||||
{
|
||||
$username = $value;
|
||||
$password = $this->getContext()->getRequest()->getParameter('user[password]');
|
||||
|
||||
if($password=="anonymous")
|
||||
{
|
||||
$error = $this->getParameterHolder()->get('password_error');
|
||||
return false;
|
||||
}
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(sfGuardUserPeer::USERNAME , $username);
|
||||
$user = sfGuardUserPeer::doSelectOne($c);
|
||||
|
||||
if(!$user)
|
||||
{
|
||||
$error = $this->getParameterHolder()->get('username_error');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(sfGuardUserGroupPeer::USER_ID , $user->getId());
|
||||
$c->add(sfGuardUserGroupPeer::GROUP_ID , 2);
|
||||
$group = sfGuardUserGroupPeer::doSelectOne($c);
|
||||
|
||||
if(!$group)
|
||||
{
|
||||
$error = $this->getParameterHolder()->get('permision_error');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($this->getContext()->getUser()->loginUser($username, $password))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$error = $this->getParameterHolder()->get('username_error');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stUser
|
||||
*
|
||||
* Ten plik należy do aplikacji stUser opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stUser
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stEditPasswordValidator.class.php 617 2009-04-09 13:02:31Z michal $
|
||||
* @author Bartosz Alejski <bartosz.alejski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa przechowuje metody walidacji formularzy użytkownika.
|
||||
*
|
||||
* @author Bartosz Alejski <bartosz.alejski@sote.pl>
|
||||
*
|
||||
* @package stUser
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stEditPasswordValidator extends sfValidator
|
||||
{
|
||||
/**
|
||||
* Zmiana hasła użytkownika.
|
||||
*
|
||||
* @param string $value
|
||||
* @param integer $error
|
||||
* @return true
|
||||
*/
|
||||
public function execute (&$value, &$error)
|
||||
{
|
||||
if ($this->getContext()->getUser()->checkPassword($this->getParameter('user[oldpassword]')) == false)
|
||||
{
|
||||
$error = $this->getParameter('error_message');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicjalizacja walidacji.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $parameters
|
||||
* @return true
|
||||
*/
|
||||
public function initialize ($context, $parameters = null)
|
||||
{
|
||||
// Initialize parent
|
||||
parent::initialize($context);
|
||||
|
||||
$user = $context->getRequest()->getParameter('user');
|
||||
|
||||
$this->setParameter('user', $user);
|
||||
|
||||
$this->getParameterHolder()->add($parameters);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user