/** * Verifies given password by given user credentials (using password salt) * when user trying to login the system first time. * * Called by doctrinemodule's authentication configuration on login. * * @static * * @param UserEntity $user * @param string $passwordGiven * * @return boolean */ public static function verifyPassword(UserEntity $user, $passwordGiven) { $verified = password_verify($passwordGiven, $user->getPassword()); if ($verified) { // You may also want to check user status here. // For example; $user->isBlacklisted() or $user->isVerified() etc.. return true; } return false; }
/** * Verifies given password by given user credentials (using password salt) * when user trying to login the system first time. * * Called by doctrinemodule's authentication configuration on login. * * @static * * @param UserEntity $user * @param string $passwordGiven * * @return boolean */ public static function verifyPassword(UserEntity $user, $passwordGiven) { return self::verifyRawPassword($user->getPassword(), $passwordGiven); }
/** * Create a new frequency event * * @param Frequency $frequency * @param type $cov * Value for the current antenna field * @param type $freqstatus * Value for the current frequency state field * @param cause Valeur du champ cause * @param Event $parent * @param \DateTime $startdate * @param User $author * @param type $messages */ public function addChangeFrequencyCovEvent(Frequency $frequency, $cov, $freqstatus, $cause, \DateTime $startdate, $enddate, \Core\Entity\User $author, Event $parent = null, &$messages = null) { $em = $this->getEntityManager(); $event = new Event(); if ($parent) { $event->setParent($parent); } $status = $em->getRepository('Application\\Entity\\Status')->find('2'); $impact = $em->getRepository('Application\\Entity\\Impact')->find('3'); $event->setImpact($impact); $event->setStatus($status); $event->setStartdate($startdate); $event->setEnddate($enddate); $event->setPunctual(false); // TODO fix horrible en attendant de gérer correctement les fréquences sans secteur if ($frequency->getDefaultsector()) { $event->setOrganisation($frequency->getDefaultsector()->getZone()->getOrganisation()); $event->addZonefilter($frequency->getDefaultsector()->getZone()); } else { $event->setOrganisation($author->getOrganisation()); } $event->setAuthor($author); $categories = $em->getRepository('Application\\Entity\\FrequencyCategory')->findBy(array('defaultfrequencycategory' => true)); if ($categories) { $cat = $categories[0]; $event->setCategory($cat); $frequencyfieldvalue = new CustomFieldValue(); $frequencyfieldvalue->setCustomField($cat->getFrequencyField()); $frequencyfieldvalue->setEvent($event); $frequencyfieldvalue->setValue($frequency->getId()); $event->addCustomFieldValue($frequencyfieldvalue); $statusfield = new CustomFieldValue(); $statusfield->setCustomField($cat->getStateField()); $statusfield->setEvent($event); $statusfield->setValue($freqstatus); $event->addCustomFieldValue($statusfield); $covfield = new CustomFieldValue(); $covfield->setCustomField($cat->getCurrentAntennaField()); $covfield->setEvent($event); $covfield->setValue($cov); $event->addCustomFieldValue($covfield); $causefield = new CustomFieldValue(); $causefield->setCustomField($cat->getCauseField()); $causefield->setEvent($event); $causefield->setValue($cause); $event->addCustomFieldValue($causefield); $em->persist($event); try { $em->flush(); if ($messages != null) { $messages['success'][] = "Changement de couverture de la fréquence " . $frequency->getValue() . " enregistré."; } } catch (\Exception $e) { if ($messages != null) { $messages['error'][] = $e->getMessage(); } else { error_log($e->getMessage()); } } } else { if ($messages != null) { $messages['error'][] = "Impossible de passer les couvertures en secours : aucune catégorie trouvée."; } } }
public function changeLocaleByUser(User $user, $newLocale) { $user->setLanguage($newLocale); $this->getObjectManager()->flush($user); return true; }
/** * Changes given user's default locale. * * @param User $user User entity to update * @param string $newLocale * * @return boolean */ public function changeLocaleByUser(User $user, $newLocale) { $user->setLanguage($newLocale); $this->userRepository->update($user); return true; }