本文整理汇总了PHP中FOS\UserBundle\Model\UserInterface::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::setPassword方法的具体用法?PHP UserInterface::setPassword怎么用?PHP UserInterface::setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOS\UserBundle\Model\UserInterface
的用法示例。
在下文中一共展示了UserInterface::setPassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: updateUser
public function updateUser(UserInterface $user, $insertInDb = false)
{
if ($this->user) {
$user->setPassword($this->user->getPassword());
$user->setId($this->user->get('id'));
$this->updateCanonicalFields($user);
}
if ($user->has('id')) {
$result = $this->pommModel->updateOne($user, ['salt', 'password', 'username_canonical', 'email_canonical']);
} else {
$this->updateCanonicalFields($user);
$this->updatePassword($user);
$this->pommModel->insertOne($user);
$this->user = $user;
}
}
示例4: updatePassword
/**
* {@inheritdoc}
*/
public function updatePassword(UserInterface $user)
{
if (0 !== strlen($password = $user->getPlainPassword())) {
$passwordDigesta = md5($user->getUsernameCanonical() . ':SabreDAV:' . $password);
$salt = $user->getSalt();
$salted = $password . '{' . $salt . '}';
$digest = hash('sha512', $salted, true);
for ($i = 1; $i < 5000; $i++) {
$digest = hash('sha512', $digest . $salted, true);
}
$encodedPassword = base64_encode($digest);
$user->setPassword($encodedPassword);
$user->setPasswordDigesta($passwordDigesta);
$user->eraseCredentials();
}
}