change phpdoc api generator to phpdoc
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security\Authentication;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Form\Form;
|
||||
|
||||
use Thelia\Core\Security\UserProvider\AdminUserProvider;
|
||||
use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator;
|
||||
use Thelia\Form\AdminLogin;
|
||||
|
||||
class AdminUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator {
|
||||
|
||||
public function __construct(Request $request, AdminLogin $loginForm) {
|
||||
parent::__construct(
|
||||
$request,
|
||||
$loginForm,
|
||||
new AdminUserProvider()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security\Authentication;
|
||||
|
||||
interface AuthenticatorInterface {
|
||||
|
||||
/**
|
||||
* Returns a UserInterface instance, authentified using the authenticator specific method
|
||||
*/
|
||||
public function getAuthentifiedUser();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security\Authentication;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator;
|
||||
use Thelia\Form\CustomerLogin;
|
||||
use Thelia\Core\Security\UserProvider\CustomerUserProvider;
|
||||
|
||||
class CustomerUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator {
|
||||
|
||||
public function __construct(Request $request, CustomerLogin $loginForm) {
|
||||
parent::__construct(
|
||||
$request,
|
||||
$loginForm,
|
||||
new CustomerUserProvider(),
|
||||
array(
|
||||
'username_field_name' => 'email'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security\Authentication;
|
||||
|
||||
use Thelia\Core\Security\Authentication\AuthenticatorInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Security\UserProvider\UserProviderInterface;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Thelia\Core\Security\Exception\WrongPasswordException;
|
||||
use Thelia\Core\Security\Exception\UsernameNotFoundException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
class UsernamePasswordFormAuthenticator implements AuthenticatorInterface {
|
||||
|
||||
protected $request;
|
||||
protected $loginForm;
|
||||
protected $userProvider;
|
||||
protected $options;
|
||||
|
||||
protected $baseLoginForm;
|
||||
|
||||
public function __construct(Request $request, BaseForm $loginForm, UserProviderInterface $userProvider, array $options = array()) {
|
||||
$this->request = $request;
|
||||
$this->baseLoginForm = $loginForm;
|
||||
$this->loginForm = $this->baseLoginForm->getForm();
|
||||
$this->userProvider = $userProvider;
|
||||
|
||||
$defaults = array(
|
||||
'required_method' => 'POST',
|
||||
'username_field_name' => 'username',
|
||||
'password_field_name' => 'password'
|
||||
);
|
||||
|
||||
$this->options = array_merge($defaults, $options);
|
||||
|
||||
$this->loginForm->bind($this->request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the username value
|
||||
*/
|
||||
public function getUsername() {
|
||||
return $this->loginForm->get($this->options['username_field_name'])->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser()
|
||||
*/
|
||||
public function getAuthentifiedUser() {
|
||||
|
||||
if ($this->request->isMethod($this->options['required_method'])) {
|
||||
|
||||
if (! $this->loginForm->isValid()) throw new ValidatorException("Form is not valid.");
|
||||
|
||||
// Retreive user
|
||||
$username = $this->getUsername();
|
||||
$password = $this->loginForm->get($this->options['password_field_name'])->getData();
|
||||
|
||||
$user = $this->userProvider->getUser($username);
|
||||
|
||||
if ($user === null) throw new UsernameNotFoundException(sprintf("Username '%s' was not found.", $username));
|
||||
|
||||
// Check user password
|
||||
$authOk = $user->checkPassword($password) === true;
|
||||
|
||||
if ($authOk !== true) throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
throw new \RuntimeException("Invalid method.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security\Exception;
|
||||
|
||||
class AuthenticationException extends \Exception
|
||||
{
|
||||
/**
|
||||
* @var string The login template name
|
||||
*/
|
||||
protected $loginTemplate = "login";
|
||||
|
||||
/**
|
||||
* @return string the login template name
|
||||
*/
|
||||
public function getLoginTemplate() {
|
||||
return $this->loginTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the login template name
|
||||
*
|
||||
* @param string $loginPath the login template name
|
||||
*/
|
||||
public function setLoginTemplate($loginTemplate) {
|
||||
$this->loginTemplate = $loginTemplate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security\Exception;
|
||||
|
||||
class UsernameNotFoundException extends AuthenticationException
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security\Exception;
|
||||
|
||||
class WrongPasswordException extends AuthenticationException
|
||||
{
|
||||
}
|
||||
|
||||
46
documentation/api/files/Core/Security/Role/Role.php.txt
Normal file
46
documentation/api/files/Core/Security/Role/Role.php.txt
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Thelia\Core\Security\Role;
|
||||
|
||||
/**
|
||||
* Role is a simple implementation of a RoleInterface where the role is a
|
||||
* string.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Role implements RoleInterface
|
||||
{
|
||||
private $role;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $role The role name
|
||||
*/
|
||||
public function __construct($role)
|
||||
{
|
||||
$this->role = (string) $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRole()
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return $this->role;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Thelia\Core\Security\Role;
|
||||
|
||||
/**
|
||||
* RoleInterface represents a role granted to a user.
|
||||
*
|
||||
* A role must either have a string representation or it needs to be explicitly
|
||||
* supported by at least one AccessDecisionManager.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface RoleInterface
|
||||
{
|
||||
/**
|
||||
* Returns the role.
|
||||
*
|
||||
* This method returns a string representation whenever possible.
|
||||
*
|
||||
* When the role cannot be represented with sufficient precision by a
|
||||
* string, it should return null.
|
||||
*
|
||||
* @return string|null A string representation of the role, or null
|
||||
*/
|
||||
public function getRole();
|
||||
}
|
||||
192
documentation/api/files/Core/Security/SecurityContext.php.txt
Normal file
192
documentation/api/files/Core/Security/SecurityContext.php.txt
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Security;
|
||||
|
||||
use Thelia\Core\Security\Authentication\AuthenticationProviderInterface;
|
||||
use Thelia\Core\Security\Exception\AuthenticationTokenNotFoundException;
|
||||
use Thelia\Core\Security\Token\TokenInterface;
|
||||
use Thelia\Core\Security\User\UserInterface;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* A simple security manager, in charge of checking user
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class SecurityContext {
|
||||
|
||||
const CONTEXT_FRONT_OFFICE = 'front';
|
||||
const CONTEXT_BACK_OFFICE = 'admin';
|
||||
|
||||
private $request;
|
||||
private $context;
|
||||
|
||||
public function __construct(Request $request) {
|
||||
|
||||
$this->request = $request;
|
||||
|
||||
$this->context = null;
|
||||
}
|
||||
|
||||
public function setContext($context) {
|
||||
if ($context !== self::CONTEXT_FRONT_OFFICE && $context !== self::CONTEXT_BACK_OFFICE) {
|
||||
throw new \InvalidArgumentException(sprintf("Invalid or empty context identifier '%s'", $context));
|
||||
}
|
||||
|
||||
$this->context = $context;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContext($exception_if_context_undefined = false) {
|
||||
if (null === $this->context && $exception_if_context_undefined === true)
|
||||
throw new \LogicException("No context defined. Please use setContext() first.");
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
private function getSession() {
|
||||
$session = $this->request->getSession();
|
||||
|
||||
if ($session === null)
|
||||
throw new \LogicException("No session found.");
|
||||
|
||||
return $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently authenticated user in the current context, or null if none is defined
|
||||
*
|
||||
* @return UserInterface|null A UserInterface instance or null if no user is available
|
||||
*/
|
||||
public function getUser() {
|
||||
$context = $this->getContext(true);
|
||||
|
||||
if ($context === self::CONTEXT_FRONT_OFFICE)
|
||||
$user = $this->getSession()->getCustomerUser();
|
||||
else if ($context == self::CONTEXT_BACK_OFFICE)
|
||||
$user = $this->getSession()->getAdminUser();
|
||||
else
|
||||
$user = null;
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
final public function isAuthenticated()
|
||||
{
|
||||
if (null !== $this->getUser()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user is allowed
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
final public function isGranted($roles, $permissions)
|
||||
{
|
||||
if ($this->isAuthenticated() === true) {
|
||||
|
||||
$user = $this->getUser();
|
||||
|
||||
// Check if user's roles matches required roles
|
||||
$userRoles = $user->getRoles();
|
||||
|
||||
$roleFound = false;
|
||||
|
||||
foreach($userRoles as $role) {
|
||||
if (in_array($role, $roles)) {
|
||||
$roleFound = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($roleFound) {
|
||||
|
||||
if (empty($permissions)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get permissions from profile
|
||||
// $userPermissions = $user->getPermissions();
|
||||
|
||||
// TODO: Finalize permissions system !;
|
||||
|
||||
$userPermissions = array('*'); // FIXME !
|
||||
|
||||
$permissionsFound = true;
|
||||
|
||||
// User have all permissions ?
|
||||
if (in_array('*', $userPermissions))
|
||||
return true;
|
||||
|
||||
// Check that user's permissions matches required permissions
|
||||
foreach($permissions as $permission) {
|
||||
if (! in_array($permission, $userPermissions)) {
|
||||
$permissionsFound = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $permissionsFound;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the authenticated user.
|
||||
*
|
||||
* @param UserInterface $user A UserInterface, or null if no further user should be stored
|
||||
*/
|
||||
public function setUser(UserInterface $user)
|
||||
{
|
||||
$context = $this->getContext(true);
|
||||
|
||||
$user->eraseCredentials();
|
||||
|
||||
if ($context === self::CONTEXT_FRONT_OFFICE)
|
||||
$this->getSession()->setCustomerUser($user);
|
||||
else if ($context == self::CONTEXT_BACK_OFFICE)
|
||||
$this->getSession()->setAdminUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the user from the security context
|
||||
*/
|
||||
public function clear() {
|
||||
$context = $this->getContext(true);
|
||||
|
||||
if ($context === self::CONTEXT_FRONT_OFFICE)
|
||||
$this->getSession()->clearCustomerUser();
|
||||
else if ($context == self::CONTEXT_BACK_OFFICE)
|
||||
$this->getSession()->clearAdminUser();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Core\Security\User;
|
||||
|
||||
/**
|
||||
* This interface should be implemented by user classes
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
interface UserInterface {
|
||||
|
||||
/**
|
||||
* Return the user unique name
|
||||
*/
|
||||
public function getUsername();
|
||||
|
||||
/**
|
||||
* Return the user encoded password
|
||||
*/
|
||||
public function getPassword();
|
||||
|
||||
/**
|
||||
* Check a string against a the user password
|
||||
*/
|
||||
public function checkPassword($password);
|
||||
|
||||
/**
|
||||
* Returns the roles granted to the user.
|
||||
*
|
||||
* <code>
|
||||
* public function getRoles()
|
||||
* {
|
||||
* return array('USER');
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @return Role[] The user roles
|
||||
*/
|
||||
public function getRoles();
|
||||
|
||||
/**
|
||||
* Removes sensitive data from the user.
|
||||
*
|
||||
* This is important if, at any given point, sensitive information like
|
||||
* the plain-text password is stored on this object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function eraseCredentials();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace Thelia\Core\Security\UserProvider;
|
||||
|
||||
use Thelia\Model\Admin;
|
||||
use Thelia\Model\AdminQuery;
|
||||
|
||||
class AdminUserProvider implements UserProviderInterface {
|
||||
|
||||
public function getUser($key) {
|
||||
|
||||
$admin = AdminQuery::create()
|
||||
->filterByLogin($key)
|
||||
->findOne();
|
||||
|
||||
return $admin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace Thelia\Core\Security\UserProvider;
|
||||
|
||||
|
||||
use Thelia\Action\Customer;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
class CustomerUserProvider implements UserProviderInterface {
|
||||
|
||||
public function getUser($key) {
|
||||
|
||||
$customer = CustomerQuery::create()
|
||||
->filterByEmail($key)
|
||||
->findOne();
|
||||
|
||||
return $customer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Core\Security\UserProvider;
|
||||
|
||||
interface UserProviderInterface {
|
||||
/**
|
||||
* Returns a UserInterface instance
|
||||
*
|
||||
* @param $key the unique user key (username, email address, etc.)
|
||||
* @return a UserInterface instance, or null if none was found.
|
||||
*/
|
||||
public function getUser($key);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user