mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Added a simple dialog for changing user settings.
This commit is contained in:
parent
e28eb3b84d
commit
62fe4afd74
5 changed files with 156 additions and 31 deletions
|
@ -33,8 +33,11 @@ namespace App\Controller;
|
|||
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Form\UserSettingsType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class UserController extends AbstractController
|
||||
|
@ -65,6 +68,32 @@ class UserController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/user/settings", name="user_settings")
|
||||
*/
|
||||
public function userSettings(Request $request, EntityManagerInterface $em)
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
//When user change its settings, he should be logged in fully.
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
|
||||
|
||||
$form = $this->createForm(UserSettingsType::class, $user);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
$this->addFlash('success', 'user.settings.saved_flash');
|
||||
}
|
||||
|
||||
return $this->render('Users/user_settings.html.twig', [
|
||||
"settings_form" => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get either a Gravatar URL or complete image tag for a specified email address.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue