mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Started to work on avatar upload from user settings page.
This commit is contained in:
parent
daba6edf5d
commit
d06701fa87
3 changed files with 76 additions and 2 deletions
|
@ -30,6 +30,7 @@ use App\Events\SecurityEvents;
|
|||
use App\Form\TFAGoogleSettingsType;
|
||||
use App\Form\UserSettingsType;
|
||||
use App\Services\UserSystem\TFA\BackupCodeManager;
|
||||
use App\Services\UserSystem\UserAvatarHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use RuntimeException;
|
||||
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticator;
|
||||
|
@ -209,7 +210,7 @@ class UserSettingsController extends AbstractController
|
|||
*
|
||||
* @return RedirectResponse|Response
|
||||
*/
|
||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager, FormFactoryInterface $formFactory)
|
||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager, FormFactoryInterface $formFactory, UserAvatarHelper $avatarHelper)
|
||||
{
|
||||
/** @var User */
|
||||
$user = $this->getUser();
|
||||
|
@ -239,6 +240,13 @@ class UserSettingsController extends AbstractController
|
|||
$page_need_reload = true;
|
||||
}
|
||||
|
||||
if ($form['avatar_file']->getData() !== null) {
|
||||
$attachment = $avatarHelper->handleAvatarUpload($user, $form['avatar_file']->getData());
|
||||
//$em->flush();
|
||||
//For some reason the avatar is not set as master picture attachment, so we do it again here
|
||||
$user->setMasterPictureAttachment($attachment);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
$this->addFlash('success', 'user.settings.saved_flash');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue