1 | <?php |
||
34 | class ForgotController extends AbstractController |
||
|
|||
35 | { |
||
36 | /** |
||
37 | * パスワードリマインダ. |
||
38 | * |
||
39 | * @param Application $app |
||
40 | * @param Request $request |
||
41 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
||
42 | */ |
||
43 | 2 | public function index(Application $app, Request $request) |
|
44 | { |
||
45 | |||
46 | 2 | $builder = $app['form.factory'] |
|
47 | 2 | ->createNamedBuilder('', ForgotType::class); |
|
48 | |||
49 | 2 | $event = new EventArgs( |
|
50 | array( |
||
51 | 2 | 'builder' => $builder, |
|
52 | ), |
||
53 | 2 | $request |
|
54 | ); |
||
55 | 2 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_FORGOT_INDEX_INITIALIZE, $event); |
|
56 | |||
57 | 2 | $form = $builder->getForm(); |
|
58 | 2 | $form->handleRequest($request); |
|
59 | |||
60 | 2 | if ($form->isSubmitted() && $form->isValid()) { |
|
61 | 1 | $Customer = $app['eccube.repository.customer'] |
|
62 | 1 | ->getActiveCustomerByEmail($form->get('login_email')->getData()); |
|
63 | |||
64 | 1 | if (!is_null($Customer)) { |
|
65 | // リセットキーの発行・有効期限の設定 |
||
66 | $Customer |
||
67 | 1 | ->setResetKey($app['eccube.repository.customer']->getUniqueResetKey($app)) |
|
68 | 1 | ->setResetExpire(new \DateTime('+' . $app['config']['customer_reset_expire'] .' min')); |
|
69 | |||
70 | // リセットキーを更新 |
||
71 | 1 | $app['orm.em']->persist($Customer); |
|
72 | 1 | $app['orm.em']->flush(); |
|
73 | |||
74 | 1 | $event = new EventArgs( |
|
75 | array( |
||
76 | 1 | 'form' => $form, |
|
77 | 1 | 'Customer' => $Customer, |
|
78 | ), |
||
79 | 1 | $request |
|
80 | ); |
||
81 | 1 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_FORGOT_INDEX_COMPLETE, $event); |
|
82 | |||
83 | // 完了URLの生成 |
||
84 | 1 | $reset_url = $app->url('forgot_reset', array('reset_key' => $Customer->getResetKey())); |
|
85 | |||
86 | // メール送信 |
||
87 | 1 | $app['eccube.service.mail']->sendPasswordResetNotificationMail($Customer, $reset_url); |
|
88 | |||
89 | // ログ出力 |
||
90 | 1 | $app['monolog']->addInfo( |
|
91 | 1 | 'send reset password mail to:' . "{$Customer->getId()} {$Customer->getEmail()} {$request->getClientIp()}" |
|
92 | ); |
||
93 | } else { |
||
94 | log_warning('Un active customer try send reset password email: ', array('Enter email' => $form->get('login_email')->getData())); |
||
95 | } |
||
96 | |||
97 | 1 | return $app->redirect($app->url('forgot_complete')); |
|
98 | } |
||
99 | |||
100 | 1 | return $app->render('Forgot/index.twig', array( |
|
101 | 1 | 'form' => $form->createView(), |
|
102 | )); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * パスワードリマインダ完了画面. |
||
107 | * |
||
108 | * @param Application $app |
||
109 | * @param Request $request |
||
110 | * @return \Symfony\Component\HttpFoundation\Response |
||
111 | */ |
||
112 | 1 | public function complete(Application $app, Request $request) |
|
116 | |||
117 | /** |
||
118 | * パスワード再発行実行画面. |
||
119 | * |
||
120 | * @param Application $app |
||
121 | * @param Request $request |
||
122 | * @param $reset_key |
||
123 | * @return \Symfony\Component\HttpFoundation\Response |
||
124 | */ |
||
125 | 3 | public function reset(Application $app, Request $request, $reset_key) |
|
181 | |||
182 | } |
||
183 |