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/shop.komma.nl/vendor/komma/kms/src/Auth/PasswordBroker.php
<?php declare(strict_types=1);


namespace Komma\KMS\Auth;

use Illuminate\Auth\Passwords\PasswordBroker as BasePasswordBroker;
use Illuminate\Support\Arr;
use UnexpectedValueException;

class PasswordBroker extends BasePasswordBroker
{
    /**
     * Send a password set link to a user.
     *
     * @param  array  $credentials
     * @return string
     */
    public function sendSetLink(array $credentials)
    {
        // First we will check to see if we found a user at the given credentials and
        // if we did not we will redirect back to this current URI with a piece of
        // "flash" data in the session to indicate to the developers the errors.
        $user = $this->getUser($credentials);

        if (is_null($user)) {
            return static::INVALID_USER;
        }

        // Once we have the reset token, we are ready to send the message out to this
        // user with a link to reset their password. We will then redirect back to
        // the current URI having nothing set in the session to indicate errors.
        if(!is_null($user)) {
            $user->sendPasswordSetNotification(
                $this->tokens->create($user)
            );
        }

        return static::RESET_LINK_SENT;
    }

    /**
     * Get the user for the given credentials.
     *
     * @throws \UnexpectedValueException
     *
     * @param array $credentials
     *
     * @return CanSetAndResetPassword|null
     *
     */
    public function getUser(array $credentials)
    {
        $credentials = Arr::except($credentials, ['token']);

        $user = $this->users->retrieveByCredentials($credentials);

        if ($user && ! $user instanceof CanSetAndResetPassword) {
            throw new UnexpectedValueException('User must implement CanSetAndResetPassword interface.');
        }

        return $user;
    }
}