master

laravel/framework

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

StatefulGuard.php

TLDR

This file is an interface called StatefulGuard that extends the Guard interface. It contains methods for authenticating users, logging them in and out, and checking if they were authenticated via a "remember me" cookie.

Methods

attempt

Attempt to authenticate a user using the given credentials.

once

Log a user into the application without sessions or cookies.

login

Log a user into the application.

loginUsingId

Log the given user ID into the application.

onceUsingId

Log the given user ID into the application without sessions or cookies.

viaRemember

Determine if the user was authenticated via "remember me" cookie.

logout

Log the user out of the application.

<?php

namespace Illuminate\Contracts\Auth;

interface StatefulGuard extends Guard
{
    /**
     * Attempt to authenticate a user using the given credentials.
     *
     * @param  array  $credentials
     * @param  bool  $remember
     * @return bool
     */
    public function attempt(array $credentials = [], $remember = false);

    /**
     * Log a user into the application without sessions or cookies.
     *
     * @param  array  $credentials
     * @return bool
     */
    public function once(array $credentials = []);

    /**
     * Log a user into the application.
     *
     * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
     * @param  bool  $remember
     * @return void
     */
    public function login(Authenticatable $user, $remember = false);

    /**
     * Log the given user ID into the application.
     *
     * @param  mixed  $id
     * @param  bool  $remember
     * @return \Illuminate\Contracts\Auth\Authenticatable|false
     */
    public function loginUsingId($id, $remember = false);

    /**
     * Log the given user ID into the application without sessions or cookies.
     *
     * @param  mixed  $id
     * @return \Illuminate\Contracts\Auth\Authenticatable|false
     */
    public function onceUsingId($id);

    /**
     * Determine if the user was authenticated via "remember me" cookie.
     *
     * @return bool
     */
    public function viaRemember();

    /**
     * Log the user out of the application.
     *
     * @return void
     */
    public function logout();
}