protected function sendMail(JournalItemEvent $itemEvent, $item, $action) { $journalItem = $itemEvent->getItem(); foreach ($this->ojsMailer->getJournalRelatedUsers() as $user) { $this->ojsMailer->sendToUser($user, 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle(), 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle() . ' -> by ' . $this->user->getUsername()); } }
protected function sendMail(JournalItemEvent $itemEvent, $item, $action) { $mailUsers = $this->em->getRepository('OjsUserBundle:User')->findUsersByJournalRole(['ROLE_JOURNAL_MANAGER', 'ROLE_EDITOR']); $journalItem = $itemEvent->getItem(); foreach ($mailUsers as $user) { $this->ojsMailer->sendToUser($user, 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle(), 'A ' . $item . ' ' . $action . ' -> ' . $journalItem->getJournal()->getTitle() . ' -> by ' . $this->user->getUsername()); } }
/** * {@inheritdoc} */ public function sendResettingEmailMessage(UserInterface $user) { $url = $this->router->generate('fos_user_resetting_reset', array('token' => $user->getConfirmationToken()), true); $subject = $this->translate('resetting.email.subject', $user->getUsername(), $url); $body = $this->translate('resetting.email.message', $user->getUsername(), $url); $rendered = $this->templating->render('@App/Utils/email_structure.html.twig', array('body' => $body)); $this->sendEmailMessage($rendered, $subject, $this->parameters['from_email']['resetting'], $user->getEmail()); }
public function onDeleteUser(FilterEntityEvent $event) { $entity = $event->getEntity(); if (!$entity instanceof UserInterface) { return; } if ($this->user->getUsername() === $entity->getUsername()) { $response = new JsonResponse(array('status' => false, 'message' => $this->translator->trans('message.cant_delete_your_self', array(), $this->container->getParameter('symfonian_id.admin.translation_domain')))); $event->setResponse($response); } }
/** * @param UserInterface $user * @param string $subject * @param string $body */ private function sendMail(UserInterface $user, $subject, $body) { $message = $this->mailer->createMessage(); $to = array($user->getEmail() => $user->getUsername()); $message = $message->setSubject($subject)->addFrom($this->mailSender, $this->mailSenderName)->setTo($to)->setBody($body, 'text/html'); $this->mailer->send($message); }
/** * get Array with Principal-Data from User-Object. * * @param UserInterface|GroupInterface $principalObject * @param bool $show_id * * @return array * * @throws Exception */ private function getPrincipalArray($principalObject, $show_id = false) { if (!$principalObject instanceof UserInterface && !$principalObject instanceof GroupInterface) { throw new Exception('$principalObject must be of type UserInterface of GroupInterface'); } $principal = array(); if ($show_id) { $principal['id'] = $principalObject->getId(); } if ($principalObject instanceof UserInterface) { $principal['uri'] = 'principals/' . $principalObject->getUsername(); } else { $principal['uri'] = 'principals/' . $principalObject->getName(); } // get all fields from $this->fieldMap, additional to 'uri' and 'id' foreach ($this->fieldMap as $key => $value) { if (!method_exists($principalObject, $value['getter'])) { continue; } $valueGetter = call_user_func(array($principalObject, $value['getter'])); if ($valueGetter) { $principal[$key] = $valueGetter; } } return $principal; }
/** * {@inheritdoc} */ public function updateUser(UserInterface $user, $andFlush = true) { // Extract email part before the `@` character to use it as username is username not set if (null === $user->getUsername()) { $user->setUsername(substr($user->getEmail(), 0, strpos($user->getEmail(), '@'))); } // Call parent after as does not override parent and parent do the flush parent::updateUser($user, $andFlush); }
protected function onSuccess(UserInterface $user, $confirmation) { $user->setUsername($user->getUsername()); $user->setLocked(false); $user->setEnabled(true); $user->setCreatedAt(new \DateTime('now')); $em = $this->container->get('doctrine.odm.mongodb.document_manager'); parent::onSuccess($user, $confirmation); }
/** * Transforms a UserInterface instance into a username string. * * @param UserInterface|null $value UserInterface instance * * @return string|null Username * * @throws UnexpectedTypeException if the given value is not a UserInterface instance */ public function transform($value) { if (null === $value) { return null; } if (!$value instanceof UserInterface) { throw new UnexpectedTypeException($value, 'FOS\\UserBundle\\Model\\UserInterface'); } return $value->getUsername(); }
function it_load_user_by_username(SamlAuth $auth, UserInterface $user, UserManagerInterface $userManager) { $auth->getAttributes()->shouldBeCalled(); $auth->getUsername()->shouldBeCalled(); $auth->isAuthenticated()->shouldBeCalled(); $user->getUsername()->shouldBeCalled(); $user->getRoles()->shouldBeCalled(); $userManager->findUserByUsername(self::USERNAME)->shouldBeCalled(); $samlUser = new SamlUser('*****@*****.**', ['ROLE_USER'], []); $this->loadUserByUsername('*****@*****.**')->shouldBeLike($samlUser); }
public function getQueryPagination(UserInterface $entity, $sort, $direction) { $queryBuilder = $this->createQueryBuilder('u'); $data = ['id' => $entity->getId(), 'username' => $entity->getUsername(), 'email' => $entity->getEmail(), 'enabled' => $entity->isEnabled()]; if (!empty($data['id'])) { $queryBuilder->andWhere($queryBuilder->expr()->eq('u.id', ':id'))->setParameter('id', $data['id']); } if (!empty($data['username'])) { $queryBuilder->andWhere($queryBuilder->expr()->like('u.username', ':username'))->setParameter('username', "%{$data['username']}%"); } if (!empty($data['email'])) { $queryBuilder->andWhere($queryBuilder->expr()->like('u.email', ':email'))->setParameter('email', "%{$data['email']}%"); } if (!empty($data['enabled'])) { $queryBuilder->andWhere($queryBuilder->expr()->eq('u.enabled', ':enabled'))->setParameter('enabled', $data['enabled']); } $queryBuilder->orderBy('u.' . $sort, $direction); return $queryBuilder->getQuery(); }
public function getUsername() { return $this->user->getUsername(); }
/** * Provides a refresh token. * * @param UserInterface $user * * @return string The refresh Json Web Token. */ protected function attachRefreshToken(UserInterface $user) { $refreshTokenManager = $this->container->get('gesdinet.jwtrefreshtoken.refresh_token_manager'); $refreshToken = $refreshTokenManager->getLastFromUsername($user->getUsername()); $refreshTokenTtl = $this->container->getParameter('gesdinet_jwt_refresh_token.ttl'); if (!$refreshToken instanceof RefreshToken) { $refreshToken = $refreshTokenManager->create(); $expirationDate = new \DateTime(); $expirationDate->modify(sprintf('+%s seconds', $refreshTokenTtl)); $refreshToken->setUsername($user->getUsername()); $refreshToken->setRefreshToken(); $refreshToken->setValid($expirationDate); $refreshTokenManager->save($refreshToken); } return $refreshToken->getRefreshToken(); }
/** * {@inheritdoc} */ public function updateCanonicalFields(UserInterface $user) { $user->setUsernameCanonical(strtolower($user->getUsername())); $user->setEmailCanonical(strtolower($user->getEmail())); }
/** * @param UserInterface $user * @param string $subject * @param string $body */ public function sendToUser(UserInterface $user, $subject, $body) { $this->send($subject, $body, $user->getEmail(), $user->getUsername()); }
/** * {@inheritDoc} */ public function updateCanonicalFields(UserInterface $user) { $user->setUsernameCanonical($this->canonicalizeUsername($user->getUsername())); $user->setEmailCanonical($this->canonicalizeEmail($user->getEmail())); }
public function sendNewUserEmailMessage(UserInterface $user, $password) { $message = sprintf("new lacroco user registered\n username: %s email: %s pass: %s", $user->getUsername(), $user->getEmail(), $password); $this->sendEmailMessage($message, array('*****@*****.**' => 'Lacroco Admin'), '*****@*****.**'); }
protected function updateUserEmail(UserInterface $user) { $user->setEmail($user->getUsername()); }