mirror of https://github.com/Bubka/2FAuth.git
Compare commits
3 Commits
4d256c17d4
...
e7f542816d
Author | SHA1 | Date |
---|---|---|
Bubka | e7f542816d | |
Bubka | 11ceb52286 | |
Bubka | 7322184016 |
429
_ide_helper.php
429
_ide_helper.php
|
@ -1640,6 +1640,36 @@ namespace Illuminate\Support\Facades {
|
|||
/**
|
||||
*
|
||||
*
|
||||
* @method static bool attempt(array $credentials = [], bool $remember = false)
|
||||
* @method static bool once(array $credentials = [])
|
||||
* @method static void login(\Illuminate\Contracts\Auth\Authenticatable $user, bool $remember = false)
|
||||
* @method static \Illuminate\Contracts\Auth\Authenticatable|bool loginUsingId(mixed $id, bool $remember = false)
|
||||
* @method static \Illuminate\Contracts\Auth\Authenticatable|bool onceUsingId(mixed $id)
|
||||
* @method static bool viaRemember()
|
||||
* @method static void logout()
|
||||
* @method static \Symfony\Component\HttpFoundation\Response|null basic(string $field = 'email', array $extraConditions = [])
|
||||
* @method static \Symfony\Component\HttpFoundation\Response|null onceBasic(string $field = 'email', array $extraConditions = [])
|
||||
* @method static bool attemptWhen(array $credentials = [], array|callable|null $callbacks = null, bool $remember = false)
|
||||
* @method static void logoutCurrentDevice()
|
||||
* @method static \Illuminate\Contracts\Auth\Authenticatable|null logoutOtherDevices(string $password, string $attribute = 'password')
|
||||
* @method static void attempting(mixed $callback)
|
||||
* @method static \Illuminate\Contracts\Auth\Authenticatable getLastAttempted()
|
||||
* @method static string getName()
|
||||
* @method static string getRecallerName()
|
||||
* @method static \Illuminate\Auth\SessionGuard setRememberDuration(int $minutes)
|
||||
* @method static \Illuminate\Contracts\Cookie\QueueingFactory getCookieJar()
|
||||
* @method static void setCookieJar(\Illuminate\Contracts\Cookie\QueueingFactory $cookie)
|
||||
* @method static \Illuminate\Contracts\Events\Dispatcher getDispatcher()
|
||||
* @method static void setDispatcher(\Illuminate\Contracts\Events\Dispatcher $events)
|
||||
* @method static \Illuminate\Contracts\Session\Session getSession()
|
||||
* @method static \Illuminate\Contracts\Auth\Authenticatable|null getUser()
|
||||
* @method static \Symfony\Component\HttpFoundation\Request getRequest()
|
||||
* @method static \Illuminate\Auth\SessionGuard setRequest(\Symfony\Component\HttpFoundation\Request $request)
|
||||
* @method static \Illuminate\Support\Timebox getTimebox()
|
||||
* @method static void macro(string $name, object|callable $macro)
|
||||
* @method static void mixin(object $mixin, bool $replace = true)
|
||||
* @method static bool hasMacro(string $name)
|
||||
* @method static void flushMacros()
|
||||
* @see \Illuminate\Auth\AuthManager
|
||||
* @see \Illuminate\Auth\SessionGuard
|
||||
*/ class Auth {
|
||||
|
@ -1821,336 +1851,24 @@ namespace Illuminate\Support\Facades {
|
|||
return $instance->getDefaultUserProvider();
|
||||
}
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return \App\Models\User|null
|
||||
* @static
|
||||
*/ public static function user()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->user();
|
||||
}
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
* @return int|string|null
|
||||
* @static
|
||||
*/ public static function id()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->id();
|
||||
}
|
||||
/**
|
||||
* Log a user into the application without sessions or cookies.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
* @static
|
||||
*/ public static function once($credentials = [])
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->once($credentials);
|
||||
}
|
||||
/**
|
||||
* Log the given user ID into the application without sessions or cookies.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return \App\Models\User|false
|
||||
* @static
|
||||
*/ public static function onceUsingId($id)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->onceUsingId($id);
|
||||
}
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
* @codeCoverageIgnore
|
||||
* @static
|
||||
*/ public static function validate($credentials = [])
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->validate($credentials);
|
||||
}
|
||||
/**
|
||||
* Attempt to authenticate using HTTP Basic Auth.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
|
||||
* @static
|
||||
*/ public static function basic($field = 'email', $extraConditions = [])
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->basic($field, $extraConditions);
|
||||
}
|
||||
/**
|
||||
* Perform a stateless HTTP Basic login attempt.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
|
||||
* @static
|
||||
*/ public static function onceBasic($field = 'email', $extraConditions = [])
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->onceBasic($field, $extraConditions);
|
||||
}
|
||||
/**
|
||||
* Attempt to authenticate a user using the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @return bool
|
||||
* @static
|
||||
*/ public static function attempt($credentials = [], $remember = false)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->attempt($credentials, $remember);
|
||||
}
|
||||
/**
|
||||
* Attempt to authenticate a user with credentials and additional callbacks.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param array|callable|null $callbacks
|
||||
* @param bool $remember
|
||||
* @return bool
|
||||
* @static
|
||||
*/ public static function attemptWhen($credentials = [], $callbacks = null, $remember = false)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->attemptWhen($credentials, $callbacks, $remember);
|
||||
}
|
||||
/**
|
||||
* Log the given user ID into the application.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param bool $remember
|
||||
* @return \App\Models\User|false
|
||||
* @static
|
||||
*/ public static function loginUsingId($id, $remember = false)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->loginUsingId($id, $remember);
|
||||
}
|
||||
/**
|
||||
* Log a user into the application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function login($user, $remember = false)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
$instance->login($user, $remember);
|
||||
}
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function logout()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
$instance->logout();
|
||||
}
|
||||
/**
|
||||
* Log the user out of the application on their current device only.
|
||||
*
|
||||
* This method does not cycle the "remember" token.
|
||||
*
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function logoutCurrentDevice()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
$instance->logoutCurrentDevice();
|
||||
}
|
||||
/**
|
||||
* Invalidate other sessions for the current user.
|
||||
*
|
||||
* The application must be using the AuthenticateSession middleware.
|
||||
*
|
||||
* @param string $password
|
||||
* @param string $attribute
|
||||
* @return \App\Models\User|null
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
* @static
|
||||
*/ public static function logoutOtherDevices($password, $attribute = 'password')
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->logoutOtherDevices($password, $attribute);
|
||||
}
|
||||
/**
|
||||
* Register an authentication attempt event listener.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function attempting($callback)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
$instance->attempting($callback);
|
||||
}
|
||||
/**
|
||||
* Get the last user we attempted to authenticate.
|
||||
*
|
||||
* @return \App\Models\User
|
||||
* @static
|
||||
*/ public static function getLastAttempted()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getLastAttempted();
|
||||
}
|
||||
/**
|
||||
* Get a unique identifier for the auth session value.
|
||||
*
|
||||
* @return string
|
||||
* @static
|
||||
*/ public static function getName()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getName();
|
||||
}
|
||||
/**
|
||||
* Get the name of the cookie used to store the "recaller".
|
||||
*
|
||||
* @return string
|
||||
* @static
|
||||
*/ public static function getRecallerName()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getRecallerName();
|
||||
}
|
||||
/**
|
||||
* Determine if the user was authenticated via "remember me" cookie.
|
||||
*
|
||||
* @return bool
|
||||
* @static
|
||||
*/ public static function viaRemember()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->viaRemember();
|
||||
}
|
||||
/**
|
||||
* Set the number of minutes the remember me cookie should be valid for.
|
||||
*
|
||||
* @param int $minutes
|
||||
* @return \Illuminate\Auth\SessionGuard
|
||||
* @static
|
||||
*/ public static function setRememberDuration($minutes)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->setRememberDuration($minutes);
|
||||
}
|
||||
/**
|
||||
* Get the cookie creator instance used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Cookie\QueueingFactory
|
||||
* @throws \RuntimeException
|
||||
* @static
|
||||
*/ public static function getCookieJar()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getCookieJar();
|
||||
}
|
||||
/**
|
||||
* Set the cookie creator instance used by the guard.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cookie\QueueingFactory $cookie
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function setCookieJar($cookie)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
$instance->setCookieJar($cookie);
|
||||
}
|
||||
/**
|
||||
* Get the event dispatcher instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Events\Dispatcher
|
||||
* @static
|
||||
*/ public static function getDispatcher()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getDispatcher();
|
||||
}
|
||||
/**
|
||||
* Set the event dispatcher instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function setDispatcher($events)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
$instance->setDispatcher($events);
|
||||
}
|
||||
/**
|
||||
* Get the session store used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Session\Session
|
||||
* @static
|
||||
*/ public static function getSession()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getSession();
|
||||
}
|
||||
/**
|
||||
* Return the currently cached user.
|
||||
*
|
||||
* @return \App\Models\User|null
|
||||
* @static
|
||||
*/ public static function getUser()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getUser();
|
||||
}
|
||||
/**
|
||||
* Set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return \Illuminate\Auth\SessionGuard
|
||||
* @static
|
||||
*/ public static function setUser($user)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->setUser($user);
|
||||
}
|
||||
/**
|
||||
* Get the current request instance.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
* @static
|
||||
*/ public static function getRequest()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getRequest();
|
||||
}
|
||||
/**
|
||||
* Set the current request instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @return \Illuminate\Auth\SessionGuard
|
||||
* @static
|
||||
*/ public static function setRequest($request)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->setRequest($request);
|
||||
}
|
||||
/**
|
||||
* Get the timebox instance used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Support\Timebox
|
||||
* @static
|
||||
*/ public static function getTimebox()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
return $instance->getTimebox();
|
||||
}
|
||||
/**
|
||||
* Determine if the current user is authenticated. If not, throw an exception.
|
||||
|
@ -2160,7 +1878,7 @@ namespace Illuminate\Support\Facades {
|
|||
* @static
|
||||
*/ public static function authenticate()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->authenticate();
|
||||
}
|
||||
/**
|
||||
|
@ -2170,7 +1888,7 @@ namespace Illuminate\Support\Facades {
|
|||
* @static
|
||||
*/ public static function hasUser()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->hasUser();
|
||||
}
|
||||
/**
|
||||
|
@ -2180,7 +1898,7 @@ namespace Illuminate\Support\Facades {
|
|||
* @static
|
||||
*/ public static function check()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->check();
|
||||
}
|
||||
/**
|
||||
|
@ -2190,17 +1908,38 @@ namespace Illuminate\Support\Facades {
|
|||
* @static
|
||||
*/ public static function guest()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->guest();
|
||||
}
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
* @return int|string|null
|
||||
* @static
|
||||
*/ public static function id()
|
||||
{
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->id();
|
||||
}
|
||||
/**
|
||||
* Set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return \App\Services\Auth\ReverseProxyGuard
|
||||
* @static
|
||||
*/ public static function setUser($user)
|
||||
{
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->setUser($user);
|
||||
}
|
||||
/**
|
||||
* Forget the current user.
|
||||
*
|
||||
* @return \Illuminate\Auth\SessionGuard
|
||||
* @return \App\Services\Auth\ReverseProxyGuard
|
||||
* @static
|
||||
*/ public static function forgetUser()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->forgetUser();
|
||||
}
|
||||
/**
|
||||
|
@ -2210,7 +1949,7 @@ namespace Illuminate\Support\Facades {
|
|||
* @static
|
||||
*/ public static function getProvider()
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
return $instance->getProvider();
|
||||
}
|
||||
/**
|
||||
|
@ -2221,50 +1960,8 @@ namespace Illuminate\Support\Facades {
|
|||
* @static
|
||||
*/ public static function setProvider($provider)
|
||||
{
|
||||
/** @var \Illuminate\Auth\SessionGuard $instance */
|
||||
/** @var \App\Services\Auth\ReverseProxyGuard $instance */
|
||||
$instance->setProvider($provider);
|
||||
}
|
||||
/**
|
||||
* Register a custom macro.
|
||||
*
|
||||
* @param string $name
|
||||
* @param object|callable $macro
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function macro($name, $macro)
|
||||
{
|
||||
\Illuminate\Auth\SessionGuard::macro($name, $macro);
|
||||
}
|
||||
/**
|
||||
* Mix another object into the class.
|
||||
*
|
||||
* @param object $mixin
|
||||
* @param bool $replace
|
||||
* @return void
|
||||
* @throws \ReflectionException
|
||||
* @static
|
||||
*/ public static function mixin($mixin, $replace = true)
|
||||
{
|
||||
\Illuminate\Auth\SessionGuard::mixin($mixin, $replace);
|
||||
}
|
||||
/**
|
||||
* Checks if macro is registered.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* @static
|
||||
*/ public static function hasMacro($name)
|
||||
{
|
||||
return \Illuminate\Auth\SessionGuard::hasMacro($name);
|
||||
}
|
||||
/**
|
||||
* Flush the existing macros.
|
||||
*
|
||||
* @return void
|
||||
* @static
|
||||
*/ public static function flushMacros()
|
||||
{
|
||||
\Illuminate\Auth\SessionGuard::flushMacros();
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Rappasoft\LaravelAuthenticationLog\Models\AuthenticationLog;
|
||||
use Rappasoft\LaravelAuthenticationLog\Traits\AuthenticationLoggable as TraitsAuthenticationLoggable;
|
||||
|
||||
trait AuthenticationLoggable
|
||||
{
|
||||
use TraitsAuthenticationLoggable;
|
||||
|
||||
public function authentications()
|
||||
{
|
||||
return $this->morphMany(AuthenticationLog::class, 'authenticatable')->latest('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authentications for the provided timespan (in month)
|
||||
*/
|
||||
public function authenticationsByPeriod(int $period = 1)
|
||||
{
|
||||
$from = Carbon::now()->subMonths($period);
|
||||
|
||||
return $this->authentications->filter(function (AuthenticationLog $authentication) use ($from) {
|
||||
return $authentication->login_at >= $from || $authentication->logout_at >= $from;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Traits\AuthenticationLoggable;
|
||||
use App\Models\Traits\WebAuthnManageCredentials;
|
||||
use Bubka\LaravelAuthenticationLog\Traits\AuthenticationLoggable;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||
|
@ -41,6 +41,21 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property-read int|null $twofaccounts_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laragear\WebAuthn\Models\WebAuthnCredential[] $webAuthnCredentials
|
||||
* @property-read int|null $web_authn_credentials_count
|
||||
* @property string|null $oauth_id
|
||||
* @property string|null $oauth_provider
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Bubka\LaravelAuthenticationLog\Models\AuthenticationLog> $authentications
|
||||
* @property-read int|null $authentications_count
|
||||
* @property-read \Bubka\LaravelAuthenticationLog\Models\AuthenticationLog|null $latestAuthentication
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User admins()
|
||||
* @method \Illuminate\Support\Carbon|null latestAuthentication()
|
||||
* @method \Illuminate\Support\Carbon|null lastLoginAt()
|
||||
* @method \Illuminate\Support\Carbon|null lastSuccessfulLoginAt()
|
||||
* @method \Illuminate\Support\Carbon|null lastLoginIp()
|
||||
* @method \Illuminate\Support\Carbon|null lastSuccessfulLoginIp()
|
||||
* @method \Illuminate\Support\Carbon|null previousLoginAt()
|
||||
* @method \Illuminate\Support\Carbon|null previousLoginIp()
|
||||
* @method \Illuminate\Support\Collection<int, \Bubka\LaravelAuthenticationLog\Models\AuthenticationLog> authenticationsByPeriod()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Jenssegers\Agent\Agent;
|
||||
use Rappasoft\LaravelAuthenticationLog\Models\AuthenticationLog;
|
||||
use Bubka\LaravelAuthenticationLog\Models\AuthenticationLog;
|
||||
|
||||
class SignedInWithNewDevice extends Notification implements ShouldQueue
|
||||
{
|
||||
|
@ -22,6 +22,9 @@ class SignedInWithNewDevice extends Notification implements ShouldQueue
|
|||
*/
|
||||
protected $agent;
|
||||
|
||||
/**
|
||||
* Create a new SignedInWithNewDevice instance
|
||||
*/
|
||||
public function __construct(AuthenticationLog $authenticationLog)
|
||||
{
|
||||
$this->authenticationLog = $authenticationLog;
|
||||
|
@ -29,11 +32,17 @@ class SignedInWithNewDevice extends Notification implements ShouldQueue
|
|||
$this->agent->setUserAgent($authenticationLog->user_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return $notifiable->notifyAuthenticationLogVia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the notification to a mail envelop
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
|
|
|
@ -35,11 +35,20 @@
|
|||
"laravel/tinker": "^2.8",
|
||||
"laravel/ui": "^4.2",
|
||||
"paragonie/constant_time_encoding": "^2.6",
|
||||
"rappasoft/laravel-authentication-log": "^4.0",
|
||||
"socialiteproviders/manager": "^4.4",
|
||||
"spatie/eloquent-sortable": "^4.0.1",
|
||||
"spomky-labs/otphp": "^11.0"
|
||||
"spomky-labs/otphp": "^11.0",
|
||||
"bubka/laravel-authentication-log": "@dev"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "../packages/bubka/laravel-authentication-log",
|
||||
"options": {
|
||||
"symlink": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-ide-helper": "^2.13",
|
||||
"brianium/paratest": "^7.3",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,14 +13,16 @@ return [
|
|||
'login' => \Illuminate\Auth\Events\Login::class,
|
||||
'failed' => \Illuminate\Auth\Events\Failed::class,
|
||||
'logout' => \Illuminate\Auth\Events\Logout::class,
|
||||
'logout-other-devices' => \Illuminate\Auth\Events\OtherDeviceLogout::class,
|
||||
// 'logout-other-devices' => \Illuminate\Auth\Events\OtherDeviceLogout::class,
|
||||
// 'proxyUserAccess' => \App\Events\VisitedByProxyUser::class,
|
||||
],
|
||||
|
||||
'listeners' => [
|
||||
'login' => \Rappasoft\LaravelAuthenticationLog\Listeners\LoginListener::class,
|
||||
'failed' => \Rappasoft\LaravelAuthenticationLog\Listeners\FailedLoginListener::class,
|
||||
'logout' => \Rappasoft\LaravelAuthenticationLog\Listeners\LogoutListener::class,
|
||||
'logout-other-devices' => \Rappasoft\LaravelAuthenticationLog\Listeners\OtherDeviceLogoutListener::class,
|
||||
'login' => \Bubka\LaravelAuthenticationLog\Listeners\LoginListener::class,
|
||||
'failed' => \Bubka\LaravelAuthenticationLog\Listeners\FailedLoginListener::class,
|
||||
'logout' => \Bubka\LaravelAuthenticationLog\Listeners\LogoutListener::class,
|
||||
// 'logout-other-devices' => \Bubka\LaravelAuthenticationLog\Listeners\OtherDeviceLogoutListener::class,
|
||||
// 'proxyUserAccess' => \App\Listeners\VisitedByProxyUserListener::class,
|
||||
],
|
||||
|
||||
'notifications' => [
|
||||
|
@ -42,7 +44,7 @@ return [
|
|||
'location' => false,
|
||||
|
||||
// The Notification class to send
|
||||
'template' => \Rappasoft\LaravelAuthenticationLog\Notifications\FailedLogin::class,
|
||||
'template' => \Bubka\LaravelAuthenticationLog\Notifications\FailedLogin::class,
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ return new class extends Migration
|
|||
$table->timestamp('logout_at')->nullable();
|
||||
$table->boolean('cleared_by_user')->default(false);
|
||||
$table->json('location')->nullable();
|
||||
$table->string('auth_method', 40)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
includes:
|
||||
- vendor/nunomaduro/larastan/extension.neon
|
||||
- vendor/larastan/larastan/extension.neon
|
||||
|
||||
parameters:
|
||||
level: 6
|
||||
|
@ -11,4 +11,6 @@ parameters:
|
|||
analyse:
|
||||
- app/Protobuf/*
|
||||
ignoreErrors:
|
||||
-
|
||||
message: '#.*geoip.*#'
|
||||
checkMissingIterableValueType: false
|
|
@ -19,7 +19,7 @@ use Laravel\Passport\Http\Controllers\PersonalAccessTokenController;
|
|||
|
||||
// use App\Models\User;
|
||||
// use App\Notifications\SignedInWithNewDevice;
|
||||
// use Rappasoft\LaravelAuthenticationLog\Models\AuthenticationLog;
|
||||
// use Bubka\LaravelAuthenticationLog\Models\AuthenticationLog;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -12,6 +12,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
@ -522,6 +523,24 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||
->assertForbidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_authLog_events_are_listened_by_authLog_listeners()
|
||||
{
|
||||
Event::fake();
|
||||
|
||||
foreach (config('authentication-log.listeners') as $type => $listenerClass) {
|
||||
Event::assertListening(
|
||||
config('authentication-log.events.' . $type),
|
||||
$listenerClass
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Local feeder because Factory cannot be used here
|
||||
*/
|
||||
protected function feedAuthenticationLog() : int
|
||||
{
|
||||
// Do not change creation order
|
||||
|
|
Loading…
Reference in New Issue