|
@@ -2,18 +2,57 @@
|
2
|
2
|
|
3
|
3
|
namespace Muzich\UserBundle\Controller;
|
4
|
4
|
|
5
|
|
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
5
|
+use Muzich\CoreBundle\lib\Controller;
|
6
|
6
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
|
7
|
+use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
8
|
+use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
|
9
|
+use FOS\UserBundle\Model\UserInterface;
|
7
|
10
|
|
8
|
11
|
class UserController extends Controller
|
9
|
12
|
{
|
10
|
|
- /**
|
11
|
|
- * @Template()
|
12
|
|
- */
|
13
|
|
- public function accountAction()
|
|
13
|
+ /**
|
|
14
|
+ * @Template()
|
|
15
|
+ */
|
|
16
|
+ public function accountAction()
|
|
17
|
+ {
|
|
18
|
+ $user = $this->getUser();
|
|
19
|
+
|
|
20
|
+ $form_password = $this->container->get('fos_user.change_password.form');
|
|
21
|
+
|
|
22
|
+ return array(
|
|
23
|
+ 'user' => $user,
|
|
24
|
+ 'form_password' => $form_password->createView()
|
|
25
|
+ );
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ public function changePasswordAction()
|
|
29
|
+ {
|
|
30
|
+ $user = $this->getUser();
|
|
31
|
+ if (!is_object($user) || !$user instanceof UserInterface) {
|
|
32
|
+ throw new AccessDeniedException('This user does not have access to this section.');
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ $form = $this->container->get('fos_user.change_password.form');
|
|
36
|
+ $formHandler = $this->container->get('fos_user.change_password.form.handler');
|
|
37
|
+
|
|
38
|
+ $process = $formHandler->process($user);
|
|
39
|
+ if ($process)
|
14
|
40
|
{
|
15
|
|
- return array(
|
16
|
|
-
|
17
|
|
- );
|
|
41
|
+ $this->container->get('session')->setFlash('fos_user_success', 'change_password.flash.success');
|
|
42
|
+ return new RedirectResponse($this->generateUrl('my_account'));
|
18
|
43
|
}
|
|
44
|
+ else
|
|
45
|
+ {
|
|
46
|
+ return $this->container->get('templating')->renderResponse(
|
|
47
|
+ 'MuzichUserBundle:User:account.html.twig',
|
|
48
|
+ array(
|
|
49
|
+ 'form_password' => $form->createView(),
|
|
50
|
+ 'user' => $user
|
|
51
|
+ )
|
|
52
|
+ );
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+ }
|
|
57
|
+
|
19
|
58
|
}
|