CakeDC\Users\Controller\Traits\PasswordManagementTrait::requestResetPassword PHP Method

requestResetPassword() public method

Reset password
public requestResetPassword ( ) : void | Response
return void | Cake\Network\Response
    public function requestResetPassword()
    {
        $this->set('user', $this->getUsersTable()->newEntity());
        $this->set('_serialize', ['user']);
        if (!$this->request->is('post')) {
            return;
        }
        $reference = $this->request->data('reference');
        try {
            $resetUser = $this->getUsersTable()->resetToken($reference, ['expiration' => Configure::read('Users.Token.expiration'), 'checkActive' => false, 'sendEmail' => true, 'ensureActive' => Configure::read('Users.Registration.ensureActive')]);
            if ($resetUser) {
                $msg = __d('CakeDC/Users', 'Please check your email to continue with password reset process');
                $this->Flash->success($msg);
            } else {
                $msg = __d('CakeDC/Users', 'The password token could not be generated. Please try again');
                $this->Flash->error($msg);
            }
            return $this->redirect(['action' => 'login']);
        } catch (UserNotFoundException $exception) {
            $this->Flash->error(__d('CakeDC/Users', 'User {0} was not found', $reference));
        } catch (UserNotActiveException $exception) {
            $this->Flash->error(__d('CakeDC/Users', 'The user is not active'));
        } catch (Exception $exception) {
            $this->Flash->error(__d('CakeDC/Users', 'Token could not be reset'));
        }
    }