Symfony2-Pommbundle和用户界面
我在symfony项目中使用pommbundle,我想使用symfony安全用户。 有可能用庞姆邦德吗 我已经创建了一个实体实现userinterface 使用者 [2017-04-25 14:24:02]security.INFO:身份验证请求失败。{“异常”:“[object](Symfony\\Component\\Security\\Core\\exception\\BadCredentialsException(代码:0):错误的凭据。at C:\\Program Files(x86)\\PostgreSQL\\EnterpriseDB ApachePHP\\apache\\www\\SITE\u CERECARE\\vendor\\symfony\\symfony\\src\\symfony\\Component\\Security\\Authentication\\Provider\\UserAuthenticationProvider.php:90,symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException(代码:0):提供的密码无效。在C:\\Program Files(x86)\\PostgreSQL\\EnterpriseDB ApachePHP\\apache\\www\\SITE\u CERECARE\\vendor\\symfony\\symfony\\src\\symfony\\Component\\Security\\Core\\Authentication\\Provider\\daoaauthenticationprovider.php:67)}[] 请求 public function findbyLogin($username) { // select employee_id, name, … from my_schema.employee where name ~* $1 $sql = strtr( "select {projection} from {relation} where \"Login\" ~* $*", [ '{projection}' => $this->createProjection(), // expand projection '{relation}' => $this->structure->getRelation(), ] ); // ↓ return an iterator on flexible entities // ↓ parameters are escaped and converted. return $this->query($sql, [$username])->current(); } } 公共函数findbyLogin($username) { //从my_schema.employee中选择employee_id,name,…,其中name~*$1 $sql=strtr( 从{relation}中选择{projection},其中\“Login\”~*$*“, [ {projection}=>this->createProjection(),//展开投影 {relation}=>this->structure->getRelation(), ] ); // ↓ 返回灵活实体上的迭代器 // ↓ 参数被转义和转换。 返回$this->query($sql,[$username])->current(); } }Symfony2-Pommbundle和用户界面,symfony,pomm,Symfony,Pomm,我在symfony项目中使用pommbundle,我想使用symfony安全用户。 有可能用庞姆邦德吗 我已经创建了一个实体实现userinterface 使用者 [2017-04-25 14:24:02]security.INFO:身份验证请求失败。{“异常”:“[object](Symfony\\Component\\Security\\Core\\exception\\BadCredentialsException(代码:0):错误的凭据。at C:\\Program Files(x86
如果您提供异常的堆栈跟踪,这将非常有用。我的帖子是在提供程序用户中使用modify refreshUser解决问题。但在日志中,我看到“php.DEBUG:pg_free_result()期望参数1是资源,如果给定{“type”:2,“file”:“C:\\Program Files(x86)\\PostgreSQL\\EnterpriseDB ApachePHP\\apache\\apache\\www\\xxxx\\vendor\\pomm project\\foundation\\sources\\lib\\Session\\ResultHandler.php”,“line”:73,“level”:28928}”你应该把答案写在回信里,然后接受它。@halfer是的,我在回信后就知道了。谢谢 security: encoders: Symfony\Component\Security\Core\User\User: plaintext AppBundle\Entity\Model\MyDb1\PublicSchema\Clientweb: sha512 role_hierarchy: ROLE_USER: ROLE_USER ROLE_PARTICULIER: ROLE_PARTICULIER ROLE_PROFESSIONNEL: ROLE_PROFESSIONNEL ROLE_SUPER_ADMIN: ROLE_ADMIN providers: in_memory: memory: users: user: { password: userpass, roles: [ 'ROLE_USER' ] } particulier: { password: parpass, roles: ['ROLE_PARTICULIER'] } professionnel: { password: propass, roles: ['ROLE_PROFESSIONNEL'] } admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] } principal: id: security_userprovider firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: pattern: ^/ anonymous: true provider: principal form_login: login_path: connexion check_path: connexion_check failure_path: connexion_failure default_target_path: compte_client always_use_default_target_path: true remember_me: name: 'CERECARE_SITE' secret: '%secret%' lifetime: 604800 path: / logout: path: deconnexion target: homepage
namespace AppBundle\Entity\Provider;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Config\Definition\Exception\Exception;
use PommProject\Foundation\Pomm;
use PommProject\Foundation\Where;
use \AppBundle\Entity\Model\MyDb1\PublicSchema\ClientwebModel;
class UserProvider implements UserProviderInterface {
private $pomm;
public function __construct(Pomm $pomm) {
$this->pomm = $pomm;
}
public function loadUserByUsername($username) {
$user = $this->pomm
->getDefaultSession()
->getModel(ClientwebModel::class)
->findbyLogin($username);
if($user!=null)
{
return $user;
}
else
{
throw new UsernameNotFoundException(sprintf('Login "%s" does not exist.', $username));
}
}
public function refreshUser(UserInterface $user) {
if (!$user instanceof User) {
throw new UnsupportedUserException(
sprintf('Instances of "%s" are not supported.', get_class($user))
);
}
return $this->loadUserByUsername($user->getUsername());
}
public function supportsClass($class) {
return $class === 'AppBundle\Entity\Model\MyDb1\PublicSchema\Clientweb';
}
}
[2017-04-25 14:24:02] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException(code: 0): Bad credentials. at C:\\Program Files (x86)\\PostgreSQL\\EnterpriseDB-ApachePHP\\apache\\www\\SITE_CERECARE\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Security\\Core\\Authentication\\Provider\\UserAuthenticationProvider.php:90, Symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException(code: 0): The presented password is invalid. at C:\\Program Files (x86)\\PostgreSQL\\EnterpriseDB-ApachePHP\\apache\\www\\SITE_CERECARE\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Security\\Core\\Authentication\\Provider\\DaoAuthenticationProvider.php:67)"} []
public function findbyLogin($username)
{
// select employee_id, name, … from my_schema.employee where name ~* $1
$sql = strtr(
"select {projection} from {relation} where \"Login\" ~* $*",
[
'{projection}' => $this->createProjection(), // expand projection
'{relation}' => $this->structure->getRelation(),
]
);
// ↓ return an iterator on flexible entities
// ↓ parameters are escaped and converted.
return $this->query($sql, [$username])->current();
}
}