HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/app/controllers/CustomerReminderController.php
<?php

use KommaApp\Shop\Customers\CustomerService;

class  CustomerReminderController extends \BaseController
{
    /**
     * @var CustomerService
     */
    private $customerService;


    /**
     * @param CustomerService $customerService
     */
    public function __construct(CustomerService $customerService)
    {
        if (\Request::has('origin')) \Session::set('origin', \Request::get('origin'));
        $this->customerService = $customerService;
    }

    public function index()
    {
        return View::make( viewPrefix() . 'customers.reminder.remind');
    }

    public function sendReminder()
    {
        $email = \Input::get('email');

        try {
            if (!$email) {
                return \Redirect::back()->withErrors(['email' => \Lang::get('customer/passwordReminder.error_email_required')]);
            }

            if (!$this->customerService->checkEmailAddress($email)) {
                return \Redirect::back()->withErrors(['email' => \Lang::get('customer/passwordReminder.error_email_unknown')]);
            }
        }
        catch(Exception $exception)
        {
            if(is_a($exception, InvalidArgumentException::class)) {
                //Catches redirect back fails with empty url.
                return;
            } else {
                //Throw the other exceptions again if there are any.
                throw new $exception;
            }
        }

        \Password::customer()->remind(['email' => $email], function ($message) {
            $from = \Config::get('mail.shop_from.' . \Shop::getDomainCountry());
            $message->sender($from['address'], $from['name']);
            $message->subject(\Lang::get('emails/auth/passwordRecovery.subject'));
        });

        return View::make( viewPrefix() . 'customers.reminder.sendReminder')->with(['email' => $email]);
    }

    public function reset()
    {
        $token = \Request::get('token');
        return View::make( viewPrefix() . 'customers.reminder.reset')
            ->with('token', $token);
    }

    public function updatePassword()
    {
        $credentials = \Input::only('email', 'password', 'password_confirmation', 'token');

        // Pre-validation before all the \Password stuff.
        $preValidation = \Validator::make(
            $credentials,
            ['email' => 'required|email', 'password' => 'min:6'],

            [
                'required' => \Lang::get('customer/passwordReminder.error_email_required'),
                'email' => \Lang::get('customer/passwordReminder.error_email_invalid'),
                'password.min' => \Lang::get('customer/create.error_password_min'),
            ]
        );

        if ($preValidation->fails())
            return \Redirect::back()
                ->withErrors($preValidation)
                ->withInput();;

        // Reset the password
        $passwordStatus = (Password::customer()->reset($credentials, function ($user, $password) {

            $user->password = \Hash::make($password);
            $user->save();
        }));
        $errors = [];
        switch ($passwordStatus) {
            case \Password::PASSWORD_RESET:

                $input = \Request::only('email', 'password');
                $input['active'] = 1;
                $input['shop_id'] = \Shop::getId();
                if (!\Auth::customer()->attempt($input)) {
                    return \Redirect::back()
                        ->withErrors($errors)
                        ->withInput();
                }

                return \Redirect::to(\Shop::getPageService()->page('customerPasswordRecovery')->route . '/success')
                    ->with('flash', \Lang::get('customer/passwordReminder.success'));
                break;
            case \Password::INVALID_PASSWORD:
                $errors['password'] = \Lang::get('customer/passwordReminder.error_password_invalid');
                break;
            case \Password::INVALID_TOKEN:
                $errors['generic'] = \Lang::get('customer/passwordReminder.error_link_expired');
                break;
            case \Password::INVALID_USER:
                $errors['email'] = \Lang::get('customer/passwordReminder.error_email_invalid');
                break;
        }
        return \Redirect::back()
            ->withErrors($errors)
            ->withInput();
    }


    public function success()
    {
        if (\Session::has('origin')) {
            return Redirect::to(str_rot13(\Session::get('origin')));
        }
        return View::make( viewPrefix() . 'customers.reminder.success');
    }
}