本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserInterface::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::isEnabled方法的具体用法?PHP UserInterface::isEnabled怎么用?PHP UserInterface::isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\User\UserInterface
的用法示例。
在下文中一共展示了UserInterface::isEnabled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRecord
/**
* @param array $record
*
* @return array
*/
public function processRecord(array $record)
{
if (is_null($this->user)) {
/* @var TokenStorageInterface $securityTokenStorage */
$securityTokenStorage = $this->container->get('security.token_storage');
if ($securityTokenStorage !== null && $securityTokenStorage->getToken() !== null && $securityTokenStorage->getToken()->getUser() instanceof \Symfony\Component\Security\Core\User\AdvancedUserInterface) {
$this->user = $securityTokenStorage->getToken()->getUser();
$this->record['extra']['user']['username'] = $this->user->getUsername();
$this->record['extra']['user']['roles'] = $this->user->getRoles();
$this->record['extra']['user']['is_account_non_expired'] = $this->user->isAccountNonExpired();
$this->record['extra']['user']['is_account_non_locked'] = $this->user->isAccountNonLocked();
$this->record['extra']['user']['is_credentials_non_expired'] = $this->user->isCredentialsNonExpired();
$this->record['extra']['user']['is_enabled'] = $this->user->isEnabled();
}
}
return array_merge($record, $this->record);
}
示例2: processRecord
/**
* @param array $record
*
* @return array
*/
public function processRecord(array $record)
{
if (is_null($this->user)) {
/* @var SecurityContextInterface $securityContext */
$securityContext = null;
try {
$this->container->get("security.context");
} catch (ServiceCircularReferenceException $e) {
//since the securitycontext is deprecated getting the context from the container results in a log line which tries to use this method again....
}
if ($securityContext !== null && $securityContext->getToken() !== null && $securityContext->getToken()->getUser() instanceof \Symfony\Component\Security\Core\User\AdvancedUserInterface) {
$this->user = $securityContext->getToken()->getUser();
$this->record['extra']['user']['username'] = $this->user->getUsername();
$this->record['extra']['user']['roles'] = $this->user->getRoles();
$this->record['extra']['user']['is_account_non_expired'] = $this->user->isAccountNonExpired();
$this->record['extra']['user']['is_account_non_locked'] = $this->user->isAccountNonLocked();
$this->record['extra']['user']['is_credentials_non_expired'] = $this->user->isCredentialsNonExpired();
$this->record['extra']['user']['is_enabled'] = $this->user->isEnabled();
}
}
return array_merge($record, $this->record);
}
示例3: checkPostAuth
/**
* {@inheritdoc}
*/
public function checkPostAuth(UserInterface $user)
{
if (!$user instanceof AdvancedUserInterface) {
return;
}
if (!$user->isAccountNonLocked()) {
throw new LockedException('User account is locked.', $user);
}
if (!$user->isEnabled()) {
throw new DisabledException('User account is disabled.', $user);
}
if (!$user->isAccountNonExpired()) {
throw new AccountExpiredException('User account has expired.', $user);
}
}
示例4: equals
/**
* Implementation of SecurityUserInterface.
*
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return Boolean
*/
public function equals(SecurityUserInterface $user)
{
if (!$user instanceof User) {
return false;
}
if ($this->getPassword() !== $user->getPassword()) {
return false;
}
if ($this->getSalt() !== $user->getSalt()) {
return false;
}
if ($this->getUsernameCanonical() !== $user->getUsernameCanonical()) {
return false;
}
if ($this->isAccountNonExpired() !== $user->isAccountNonExpired()) {
return false;
}
if ($this->isAccountNonLocked() !== $user->isAccountNonLocked()) {
return false;
}
if ($this->isCredentialsNonExpired() !== $user->isCredentialsNonExpired()) {
return false;
}
if ($this->isEnabled() !== $user->isEnabled()) {
return false;
}
return true;
}
示例5: isEnabled
public function isEnabled()
{
return $this->wrappedUser instanceof AdvancedUserInterface ? $this->wrappedUser->isEnabled() : true;
}
示例6: equals
public function equals(UserInterface $user)
{
if (!$user instanceof User) {
return false;
}
if ($this->password !== $user->getPassword()) {
return false;
}
if ($this->getSalt() !== $user->getSalt()) {
return false;
}
if ($this->isAccountNonExpired() !== $user->isAccountNonExpired()) {
return false;
}
if (!$this->locked !== $user->isAccountNonLocked()) {
return false;
}
if ($this->isCredentialsNonExpired() !== $user->isCredentialsNonExpired()) {
return false;
}
if ($this->enabled !== $user->isEnabled()) {
return false;
}
return true;
}