master

laravel/framework

Last updated at: 29/12/2023 09:20

TokenRepositoryInterface.php

TLDR

This file is the interface definition for the TokenRepository class in the Illuminate/Auth/Passwords namespace. It defines the methods that can be used to manage password reset tokens.

Methods

create

Creates a new token for a user who wants to reset their password.

exists

Checks if a token record exists and is valid for a given user and token.

recentlyCreatedToken

Checks if the given user recently created a password reset token.

delete

Deletes a token record for a given user.

deleteExpired

Deletes expired tokens from the repository.

<?php

namespace Illuminate\Auth\Passwords;

use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

interface TokenRepositoryInterface
{
    /**
     * Create a new token.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @return string
     */
    public function create(CanResetPasswordContract $user);

    /**
     * Determine if a token record exists and is valid.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @param  string  $token
     * @return bool
     */
    public function exists(CanResetPasswordContract $user, $token);

    /**
     * Determine if the given user recently created a password reset token.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @return bool
     */
    public function recentlyCreatedToken(CanResetPasswordContract $user);

    /**
     * Delete a token record.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @return void
     */
    public function delete(CanResetPasswordContract $user);

    /**
     * Delete expired tokens.
     *
     * @return void
     */
    public function deleteExpired();
}