merged 2.0
This commit is contained in:
commit
cd77327e9a
@ -11,8 +11,27 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Security\Core\User;
|
namespace Symfony\Component\Security\Core\User;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Exception\AccountStatusException;
|
||||||
|
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
|
||||||
|
use Symfony\Component\Security\Core\Exception\LockedException;
|
||||||
|
use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
|
||||||
|
use Symfony\Component\Security\Core\Exception\DisabledException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AdvancedUserInterface adds status flags to a regular account.
|
* Adds extra features to a user class related to account status flags.
|
||||||
|
*
|
||||||
|
* This interface can be implemented in place of UserInterface if you'd like
|
||||||
|
* the authentication system to consider different account status flags
|
||||||
|
* during authentication. If any of the methods in this interface return
|
||||||
|
* false, authentication will fail.
|
||||||
|
*
|
||||||
|
* If you need to perform custom logic for any of these situations, then
|
||||||
|
* you will need to register an exception listener and watch for the specific
|
||||||
|
* exception instances thrown in each case. All exceptions are a subclass
|
||||||
|
* of AccountStatusException
|
||||||
|
*
|
||||||
|
* @see UserInterface
|
||||||
|
* @see AccountStatusException
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
@ -21,28 +40,48 @@ interface AdvancedUserInterface extends UserInterface
|
|||||||
/**
|
/**
|
||||||
* Checks whether the user's account has expired.
|
* Checks whether the user's account has expired.
|
||||||
*
|
*
|
||||||
|
* Internally, if this method returns false, the authentication system
|
||||||
|
* will throw an AccountExpiredException and prevent login.
|
||||||
|
*
|
||||||
* @return Boolean true if the user's account is non expired, false otherwise
|
* @return Boolean true if the user's account is non expired, false otherwise
|
||||||
|
*
|
||||||
|
* @see AccountExpiredException
|
||||||
*/
|
*/
|
||||||
function isAccountNonExpired();
|
function isAccountNonExpired();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the user is locked.
|
* Checks whether the user is locked.
|
||||||
*
|
*
|
||||||
|
* Internally, if this method returns false, the authentication system
|
||||||
|
* will throw a LockedException and prevent login.
|
||||||
|
*
|
||||||
* @return Boolean true if the user is not locked, false otherwise
|
* @return Boolean true if the user is not locked, false otherwise
|
||||||
|
*
|
||||||
|
* @see LockedException
|
||||||
*/
|
*/
|
||||||
function isAccountNonLocked();
|
function isAccountNonLocked();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the user's credentials (password) has expired.
|
* Checks whether the user's credentials (password) has expired.
|
||||||
*
|
*
|
||||||
|
* Internally, if this method returns false, the authentication system
|
||||||
|
* will throw a CredentialsExpiredException and prevent login.
|
||||||
|
*
|
||||||
* @return Boolean true if the user's credentials are non expired, false otherwise
|
* @return Boolean true if the user's credentials are non expired, false otherwise
|
||||||
|
*
|
||||||
|
* @see CredentialsExpiredException
|
||||||
*/
|
*/
|
||||||
function isCredentialsNonExpired();
|
function isCredentialsNonExpired();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the user is enabled.
|
* Checks whether the user is enabled.
|
||||||
*
|
*
|
||||||
|
* Internally, if this method returns false, the authentication system
|
||||||
|
* will throw a DisabledException and prevent login.
|
||||||
|
*
|
||||||
* @return Boolean true if the user is enabled, false otherwise
|
* @return Boolean true if the user is enabled, false otherwise
|
||||||
|
*
|
||||||
|
* @see DisabledException
|
||||||
*/
|
*/
|
||||||
function isEnabled();
|
function isEnabled();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,20 @@
|
|||||||
namespace Symfony\Component\Security\Core\User;
|
namespace Symfony\Component\Security\Core\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserInterface is the interface that user classes must implement.
|
* Represents the interface that all user classes must implement.
|
||||||
|
*
|
||||||
|
* This interface is useful because the authentication layer can deal with
|
||||||
|
* the object through its lifecycle, using the object to get the encoded
|
||||||
|
* password (for checking against a submitted password), assigning roles
|
||||||
|
* and so on.
|
||||||
|
*
|
||||||
|
* Regardless of how your user are loaded or where they come from (a database,
|
||||||
|
* configuration, web service, etc), you will have a class that implements
|
||||||
|
* this interface. Objects that implement this interface are created and
|
||||||
|
* loaded by different objects that implement UserProviderInterface
|
||||||
|
*
|
||||||
|
* @see UserProviderInterface
|
||||||
|
* @see AdvancedUserInterface
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
@ -21,6 +34,17 @@ interface UserInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the roles granted to the user.
|
* Returns the roles granted to the user.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* public function getRoles()
|
||||||
|
* {
|
||||||
|
* return array('ROLE_USER');
|
||||||
|
* }
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* Alternatively, the roles might be stored on a ``roles`` property,
|
||||||
|
* and populated in any number of different ways when the user object
|
||||||
|
* is created.
|
||||||
|
*
|
||||||
* @return Role[] The user roles
|
* @return Role[] The user roles
|
||||||
*/
|
*/
|
||||||
function getRoles();
|
function getRoles();
|
||||||
@ -28,12 +52,17 @@ interface UserInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the password used to authenticate the user.
|
* Returns the password used to authenticate the user.
|
||||||
*
|
*
|
||||||
|
* This should be the encoded password. On authentication, a plain-text
|
||||||
|
* password will be salted, encoded, and then compared to this value.
|
||||||
|
*
|
||||||
* @return string The password
|
* @return string The password
|
||||||
*/
|
*/
|
||||||
function getPassword();
|
function getPassword();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the salt.
|
* Returns the salt that was originally used to encode the password.
|
||||||
|
*
|
||||||
|
* This can return null if the password was not encoded using a salt.
|
||||||
*
|
*
|
||||||
* @return string The salt
|
* @return string The salt
|
||||||
*/
|
*/
|
||||||
@ -48,10 +77,17 @@ interface UserInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes sensitive data from the user.
|
* 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
|
||||||
*/
|
*/
|
||||||
function eraseCredentials();
|
function eraseCredentials();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns whether or not the given user is equivalent to *this* user.
|
||||||
|
*
|
||||||
* The equality comparison should neither be done by referential equality
|
* The equality comparison should neither be done by referential equality
|
||||||
* nor by comparing identities (i.e. getId() === getId()).
|
* nor by comparing identities (i.e. getId() === getId()).
|
||||||
*
|
*
|
||||||
|
@ -11,9 +11,23 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Security\Core\User;
|
namespace Symfony\Component\Security\Core\User;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserProviderInterface is the implementation that all user provider must
|
* Represents a class that loads UserInterface objects from some source for the authentication system.
|
||||||
* implement.
|
*
|
||||||
|
* In a typical authentication configuration, a username (i.e. some unique
|
||||||
|
* user identifier) credential enters the system (via form login, or any
|
||||||
|
* method). The user provider that is configured with that authentication
|
||||||
|
* method is asked to load the UserInterface object for the given username
|
||||||
|
* (via loadUserByUsername) so that the rest of the process can continue.
|
||||||
|
*
|
||||||
|
* Internally, a user provider can load users from any source (databases,
|
||||||
|
* configuration, web service). This is totally independent of how the authentication
|
||||||
|
* information is submitted or what the UserInterface object looks like.
|
||||||
|
*
|
||||||
|
* @see UserInterface
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
@ -25,24 +39,29 @@ interface UserProviderInterface
|
|||||||
* This method must throw UsernameNotFoundException if the user is not
|
* This method must throw UsernameNotFoundException if the user is not
|
||||||
* found.
|
* found.
|
||||||
*
|
*
|
||||||
* @throws UsernameNotFoundException if the user is not found
|
|
||||||
* @param string $username The username
|
* @param string $username The username
|
||||||
*
|
*
|
||||||
* @return UserInterface
|
* @return UserInterface
|
||||||
|
*
|
||||||
|
* @see UsernameNotFoundException
|
||||||
|
*
|
||||||
|
* @throws UsernameNotFoundException if the user is not found
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function loadUserByUsername($username);
|
function loadUserByUsername($username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the user for the account interface.
|
* Refreshes the user for the account interface.
|
||||||
*
|
*
|
||||||
* It is up to the implementation if it decides to reload the user data
|
* It is up to the implementation to decide if the user data should be
|
||||||
* from the database, or if it simply merges the passed User into the
|
* totally reloaded (e.g. from the database), or if the UserInterface
|
||||||
* identity map of an entity manager.
|
* object can just be merged into some internal array of users / identity
|
||||||
*
|
* map.
|
||||||
* @throws UnsupportedUserException if the account is not supported
|
|
||||||
* @param UserInterface $user
|
* @param UserInterface $user
|
||||||
*
|
*
|
||||||
* @return UserInterface
|
* @return UserInterface
|
||||||
|
*
|
||||||
|
* @throws UnsupportedUserException if the account is not supported
|
||||||
*/
|
*/
|
||||||
function refreshUser(UserInterface $user);
|
function refreshUser(UserInterface $user);
|
||||||
|
|
||||||
|
@ -154,15 +154,20 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|||||||
protected function evaluate(Storage $template, array $parameters = array())
|
protected function evaluate(Storage $template, array $parameters = array())
|
||||||
{
|
{
|
||||||
$__template__ = $template;
|
$__template__ = $template;
|
||||||
|
|
||||||
|
if (isset($parameters['__template__'])) {
|
||||||
|
throw new \InvalidArgumentException('Invalid parameter (__template__)');
|
||||||
|
}
|
||||||
|
|
||||||
if ($__template__ instanceof FileStorage) {
|
if ($__template__ instanceof FileStorage) {
|
||||||
extract($parameters);
|
extract($parameters, EXTR_SKIP);
|
||||||
$view = $this;
|
$view = $this;
|
||||||
ob_start();
|
ob_start();
|
||||||
require $__template__;
|
require $__template__;
|
||||||
|
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
} elseif ($__template__ instanceof StringStorage) {
|
} elseif ($__template__ instanceof StringStorage) {
|
||||||
extract($parameters);
|
extract($parameters, EXTR_SKIP);
|
||||||
$view = $this;
|
$view = $this;
|
||||||
ob_start();
|
ob_start();
|
||||||
eval('; ?>'.$__template__.'<?php ;');
|
eval('; ?>'.$__template__.'<?php ;');
|
||||||
|
Reference in New Issue
Block a user