本文整理汇总了PHP中FOS\UserBundle\Model\UserInterface::getPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::getPassword方法的具体用法?PHP UserInterface::getPassword怎么用?PHP UserInterface::getPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOS\UserBundle\Model\UserInterface
的用法示例。
在下文中一共展示了UserInterface::getPassword方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUserByOAuthUserResponse
/**
* Attach OAuth sign-in provider account to existing user
*
* @param FOSUserInterface $user
* @param UserResponseInterface $response
*
* @return FOSUserInterface
*/
protected function updateUserByOAuthUserResponse(FOSUserInterface $user, UserResponseInterface $response)
{
$providerName = $response->getResourceOwner()->getName();
$providerNameSetter = 'set' . ucfirst($providerName) . 'Id';
$user->{$providerNameSetter}($response->getUsername());
if (!$user->getPassword()) {
// generate unique token
$secret = md5(uniqid(rand(), true));
$user->setPassword($secret);
}
return $user;
}
示例2: updateUserByOAuthUserResponse
/**
* Attach OAuth sign-in provider account to existing user
*
* @param FOSUserInterface $user
* @param UserResponseInterface $response
*
* @return FOSUserInterface
*/
protected function updateUserByOAuthUserResponse(FOSUserInterface $user, UserResponseInterface $response)
{
$providerName = $response->getResourceOwner()->getName();
$providerNameSetter = 'set' . ucfirst($providerName) . 'Id';
$user->{$providerNameSetter}($response->getUsername());
/** Is for accept OAuth connexion without password **/
if (!$user->getPassword()) {
$secret = md5(uniqid(rand(), true));
$user->setPassword($secret);
}
return $user;
}
示例3: userLoginAction
/**
* add the symfony-login "manually".
*
* use the symfony token-storage for the generated UsernamePasswordToken
* to access the (logged in) user later (e.g. to check for roles or permissions)
*
* the given $passwordHash must match the encrypted password in the user-object
*
* before and after the generation/setting of the token, the events "secotrust.user_login.before"
* and "secotrust.user_login.after" are called, if some EventListeners are configured
*
* @param \FOS\UserBundle\Model\UserInterface $user
* @param $passwordHash
*/
private function userLoginAction(\FOS\UserBundle\Model\UserInterface $user, $passwordHash)
{
// call the pre-login-event
$event = new Event();
$this->dispatcher->dispatch('secotrust.user_login.before', $event);
if ($user->getPassword() !== $passwordHash) {
// stop the login-action, when the password doesn't match
return;
}
$token = new UsernamePasswordToken($user, null, 'secured_area', $user->getRoles());
$this->token_storage->setToken($token);
// call the post-login-event
$event = new Event();
$this->dispatcher->dispatch('secotrust.user_login.after', $event);
}