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