1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of EC-CUBE |
4
|
|
|
* |
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
6
|
|
|
* |
7
|
|
|
* http://www.lockon.co.jp/ |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU General Public License |
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
12
|
|
|
* of the License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with this program; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
namespace Eccube\Controller\Mypage; |
26
|
|
|
|
27
|
|
|
use Eccube\Application; |
28
|
|
|
use Eccube\Controller\AbstractController; |
29
|
|
|
use Symfony\Component\HttpFoundation\Request; |
30
|
|
|
|
31
|
|
|
class ChangeController extends AbstractController |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* Index |
35
|
|
|
* |
36
|
|
|
* @param Application $app |
37
|
|
|
* @param Request $request |
|
|
|
|
38
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
39
|
|
|
*/ |
40
|
4 |
|
public function index(Application $app, Request $request) |
41
|
|
|
{ |
42
|
|
|
$Customer = $app->user(); |
43
|
4 |
|
$LoginCustomer = clone $Customer; |
44
|
|
|
$app['orm.em']->detach($LoginCustomer); |
45
|
|
|
|
46
|
|
|
$previous_password = $Customer->getPassword(); |
47
|
|
|
$Customer->setPassword($app['config']['default_password']); |
48
|
|
|
|
49
|
|
|
/* @var $builder \Symfony\Component\Form\FormBuilderInterface */ |
50
|
|
|
$builder = $app['form.factory']->createBuilder('entry', $Customer); |
51
|
|
|
|
52
|
|
|
/* @var $form \Symfony\Component\Form\FormInterface */ |
53
|
|
|
$form = $builder->getForm(); |
54
|
|
|
$form->handleRequest($request); |
55
|
|
|
|
56
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
57
|
|
View Code Duplication |
if ($Customer->getPassword() === $app['config']['default_password']) { |
|
|
|
|
58
|
|
|
$Customer->setPassword($previous_password); |
59
|
|
|
} else { |
60
|
|
|
$Customer->setPassword( |
61
|
|
|
$app['eccube.repository.customer']->encryptPassword($app, $Customer) |
62
|
|
|
); |
63
|
1 |
|
} |
64
|
|
|
$app['orm.em']->flush(); |
65
|
|
|
|
66
|
|
|
return $app->redirect($app->url('mypage_change_complete')); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$app['security']->getToken()->setUser($LoginCustomer); |
70
|
|
|
|
71
|
2 |
|
return $app->renderView('Mypage/change.twig', array( |
72
|
2 |
|
'form' => $form->createView(), |
73
|
|
|
)); |
74
|
4 |
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Complete |
78
|
|
|
* |
79
|
|
|
* @param Application $app |
80
|
|
|
* @param Request $request |
|
|
|
|
81
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
82
|
|
|
*/ |
83
|
1 |
|
public function complete(Application $app, Request $request) |
|
|
|
|
84
|
|
|
{ |
85
|
|
|
return $app->renderView('Mypage/change_complete.twig'); |
86
|
1 |
|
} |
87
|
|
|
} |
88
|
|
|
|