コード例 #1
0
ファイル: UserManager.php プロジェクト: GTheron/CRM-back
 public function resetPassword(UserInterface $user)
 {
     if ($user->isPasswordRequestNonExpired(86400) == false) {
         $user->setConfirmationToken(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36));
         $url = $this->host . $this->router->generate('asi_individual_password_is_reset', array('token' => $user->getConfirmationToken()));
         $today = new \DateTime();
         $today->format('Y-m-d H:i:s');
         $user->setPasswordRequestedAt($today);
         $this->rm->update($user);
         $event = new EventAssociatedWithUser($url, $user, null);
         $this->eventDispatcher->dispatch(User::USER_REQUESTED_NEW_PASSWORD, $event);
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function isGrantedRoles(array $roles, UserInterface $user)
 {
     $token = new UsernamePasswordToken($user, 'none', 'none', $user->getRoles());
     return $this->decisionManager->decide($token, $roles);
 }