1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-16 18:01:38 +00:00

Updating logged in user (email, name, etc ..)

This commit is contained in:
Jeremy 2015-02-17 22:45:20 +01:00
parent d9085c63e3
commit c0d9eba07f
7 changed files with 185 additions and 20 deletions

View file

@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Form\Type\ConfigType;
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
use Wallabag\CoreBundle\Form\Type\UserType;
class ConfigController extends Controller
{
@ -20,13 +21,13 @@ class ConfigController extends Controller
{
$em = $this->getDoctrine()->getManager();
$config = $this->getConfig();
$user = $this->getUser();
// handle basic config detail
$configForm = $this->createForm(new ConfigType(), $config);
$configForm->handleRequest($request);
if ($configForm->isValid()) {
$em->persist($config);
$em->flush();
@ -43,7 +44,6 @@ class ConfigController extends Controller
$pwdForm->handleRequest($request);
if ($pwdForm->isValid()) {
$user = $this->getUser();
$user->setPassword($pwdForm->get('new_password')->getData());
$em->persist($user);
$em->flush();
@ -56,9 +56,26 @@ class ConfigController extends Controller
return $this->redirect($this->generateUrl('config'));
}
// handle changing user information
$userForm = $this->createForm(new UserType(), $user);
$userForm->handleRequest($request);
if ($userForm->isValid()) {
$em->persist($user);
$em->flush();
$this->get('session')->getFlashBag()->add(
'notice',
'Information updated'
);
return $this->redirect($this->generateUrl('config'));
}
return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
'configForm' => $configForm->createView(),
'pwdForm' => $pwdForm->createView(),
'userForm' => $userForm->createView(),
));
}