mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 05:54:32 +02:00
Fixed some deprecations.
This commit is contained in:
parent
2a332b28a7
commit
193ecd252b
12 changed files with 66 additions and 24 deletions
|
@ -76,6 +76,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -106,7 +107,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
protected $entityManager;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, UserPasswordEncoderInterface $passwordEncoder,
|
||||
public function __construct(TranslatorInterface $translator, UserPasswordHasherInterface $passwordEncoder,
|
||||
AttachmentSubmitHandler $attachmentSubmitHandler,
|
||||
EventCommentHelper $commentHelper, HistoryHelper $historyHelper, TimeTravel $timeTravel,
|
||||
DataTableFactory $dataTableFactory, EventDispatcherInterface $eventDispatcher, BarcodeExampleElementsGenerator $barcodeExampleGenerator,
|
||||
|
|
|
@ -66,6 +66,7 @@ use Symfony\Component\Form\FormInterface;
|
|||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -88,7 +89,7 @@ class CurrencyController extends BaseAdminController
|
|||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
UserPasswordEncoderInterface $passwordEncoder,
|
||||
UserPasswordHasherInterface $passwordEncoder,
|
||||
AttachmentSubmitHandler $attachmentSubmitHandler,
|
||||
EventCommentHelper $commentHelper,
|
||||
HistoryHelper $historyHelper,
|
||||
|
|
|
@ -82,7 +82,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
{
|
||||
//Check if we editing a user and if we need to change the password of it
|
||||
if ($entity instanceof User && !empty($form['new_password']->getData())) {
|
||||
$password = $this->passwordEncoder->encodePassword($entity, $form['new_password']->getData());
|
||||
$password = $this->passwordEncoder->hashPassword($entity, $form['new_password']->getData());
|
||||
$entity->setPassword($password);
|
||||
//By default the user must change the password afterwards
|
||||
$entity->setNeedPwChange(true);
|
||||
|
@ -134,7 +134,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
protected function additionalActionNew(FormInterface $form, AbstractNamedDBElement $entity): bool
|
||||
{
|
||||
if ($entity instanceof User && !empty($form['new_password']->getData())) {
|
||||
$password = $this->passwordEncoder->encodePassword($entity, $form['new_password']->getData());
|
||||
$password = $this->passwordEncoder->hashPassword($entity, $form['new_password']->getData());
|
||||
$entity->setPassword($password);
|
||||
//By default the user must change the password afterwards
|
||||
$entity->setNeedPwChange(true);
|
||||
|
|
|
@ -61,6 +61,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
|
||||
|
@ -199,7 +200,7 @@ class UserSettingsController extends AbstractController
|
|||
*
|
||||
* @return RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
|
||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
|
||||
{
|
||||
/** @var User */
|
||||
$user = $this->getUser();
|
||||
|
@ -284,7 +285,7 @@ class UserSettingsController extends AbstractController
|
|||
|
||||
//Check if password if everything was correct, then save it to User and DB
|
||||
if (!$this->demo_mode && $pw_form->isSubmitted() && $pw_form->isValid()) {
|
||||
$password = $passwordEncoder->encodePassword($user, $pw_form['new_password']->getData());
|
||||
$password = $passwordEncoder->hashPassword($user, $pw_form['new_password']->getData());
|
||||
$user->setPassword($password);
|
||||
|
||||
//After the change reset the password change needed setting
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue