mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-12 06:59:04 +02:00
Fix phpstan & pint issues
This commit is contained in:
@ -311,7 +311,7 @@ class TwoFAccountController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Checks ids length
|
* Checks ids length
|
||||||
*
|
*
|
||||||
* @param string $ids comma-separated ids
|
* @param string $ids comma-separated ids
|
||||||
* @return bool whether or not the number of ids is acceptable
|
* @return bool whether or not the number of ids is acceptable
|
||||||
*/
|
*/
|
||||||
private function tooManyIds(string $ids) : bool
|
private function tooManyIds(string $ids) : bool
|
||||||
|
@ -130,9 +130,9 @@ class UserManagerController extends Controller
|
|||||||
$tokens = $tokenRepository->forUser($user->getAuthIdentifier());
|
$tokens = $tokenRepository->forUser($user->getAuthIdentifier());
|
||||||
|
|
||||||
$tokens->load('client')->filter(function ($token) {
|
$tokens->load('client')->filter(function ($token) {
|
||||||
return $token->client->personal_access_client && ! $token->revoked;
|
return $token->client->personal_access_client && ! $token->revoked; /** @phpstan-ignore-line */
|
||||||
})->each(function ($token) {
|
})->each(function ($token) {
|
||||||
$token->revoke();
|
$token->revoke(); /** @phpstan-ignore-line */
|
||||||
});
|
});
|
||||||
|
|
||||||
Log::info(sprintf('All personal access tokens for User ID #%s have been revoked', $user->id));
|
Log::info(sprintf('All personal access tokens for User ID #%s have been revoked', $user->id));
|
||||||
@ -188,7 +188,7 @@ class UserManagerController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Promote (or demote) a user
|
* Promote (or demote) a user
|
||||||
*
|
*
|
||||||
* @return \App\Api\v1\Resources\UserManagerResource
|
* @return \App\Api\v1\Resources\UserManagerResource|\Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function promote(UserManagerPromoteRequest $request, User $user)
|
public function promote(UserManagerPromoteRequest $request, User $user)
|
||||||
{
|
{
|
||||||
@ -209,7 +209,7 @@ class UserManagerController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Get the user's authentication logs
|
* Get the user's authentication logs
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||||
*/
|
*/
|
||||||
public function authentications(Request $request, User $user)
|
public function authentications(Request $request, User $user)
|
||||||
{
|
{
|
||||||
@ -217,7 +217,7 @@ class UserManagerController extends Controller
|
|||||||
|
|
||||||
$validated = $this->validate($request, [
|
$validated = $this->validate($request, [
|
||||||
'period' => 'sometimes|numeric',
|
'period' => 'sometimes|numeric',
|
||||||
'limit' => 'sometimes|numeric',
|
'limit' => 'sometimes|numeric',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$authentications = $request->has('period') ? $user->authenticationsByPeriod($validated['period']) : $user->authentications;
|
$authentications = $request->has('period') ? $user->authenticationsByPeriod($validated['period']) : $user->authentications;
|
||||||
|
@ -9,11 +9,15 @@ use Jenssegers\Agent\Agent;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @property mixed $id
|
* @property mixed $id
|
||||||
* @property string $name
|
* @property string $ip_address
|
||||||
* @property string $email
|
* @property string $user_agent
|
||||||
* @property string $oauth_provider
|
* @property string $browser
|
||||||
* @property \Illuminate\Support\Collection<array-key, mixed> $preferences
|
* @property string $platform
|
||||||
* @property string $is_admin
|
* @property string $device
|
||||||
|
* @property Carbon|null $login_at
|
||||||
|
* @property Carbon|null $logout_at
|
||||||
|
* @property bool $login_successful
|
||||||
|
* @property string|null $duration
|
||||||
*/
|
*/
|
||||||
class UserAuthentication extends JsonResource
|
class UserAuthentication extends JsonResource
|
||||||
{
|
{
|
||||||
@ -47,16 +51,16 @@ class UserAuthentication extends JsonResource
|
|||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'ip_address' => $this->ip_address,
|
'ip_address' => $this->ip_address,
|
||||||
'user_agent' => $this->user_agent,
|
'user_agent' => $this->user_agent,
|
||||||
'browser' => $this->agent->browser(),
|
'browser' => $this->agent->browser(),
|
||||||
'platform' => $this->agent->platform(),
|
'platform' => $this->agent->platform(),
|
||||||
'device' => $this->agent->deviceType(),
|
'device' => $this->agent->deviceType(),
|
||||||
'login_at' => $this->login_at
|
'login_at' => $this->login_at
|
||||||
? Carbon::parse($this->login_at)->toDayDateTimeString()
|
? Carbon::parse($this->login_at)->toDayDateTimeString()
|
||||||
: null,
|
: null,
|
||||||
'logout_at' => $this->logout_at
|
'logout_at' => $this->logout_at
|
||||||
? Carbon::parse($this->logout_at)->toDayDateTimeString()
|
? Carbon::parse($this->logout_at)->toDayDateTimeString()
|
||||||
: null,
|
: null,
|
||||||
'login_successful' => $this->login_successful,
|
'login_successful' => $this->login_successful,
|
||||||
|
@ -55,7 +55,7 @@ class UserManagerResource extends UserResource
|
|||||||
$tokens = $tokenRepository->forUser($this->resource->getAuthIdentifier());
|
$tokens = $tokenRepository->forUser($this->resource->getAuthIdentifier());
|
||||||
|
|
||||||
$PATs_count = $tokens->load('client')->filter(function ($token) {
|
$PATs_count = $tokens->load('client')->filter(function ($token) {
|
||||||
return $token->client->personal_access_client && ! $token->revoked;
|
return $token->client->personal_access_client && ! $token->revoked; /** @phpstan-ignore-line */
|
||||||
})->count();
|
})->count();
|
||||||
|
|
||||||
$this->with = [
|
$this->with = [
|
||||||
|
@ -80,7 +80,7 @@ class RemoteUserProvider implements UserProvider
|
|||||||
/**
|
/**
|
||||||
* Set a fake email address
|
* Set a fake email address
|
||||||
*
|
*
|
||||||
* @param $id mixed
|
* @param $id mixed
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function fakeRemoteEmail(mixed $id)
|
protected function fakeRemoteEmail(mixed $id)
|
||||||
|
@ -19,7 +19,7 @@ class MigratorFactory implements MigratorFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Infer the type of migrator needed from a payload and create the migrator
|
* Infer the type of migrator needed from a payload and create the migrator
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload The migration payload used to infer the migrator type
|
* @param string $migrationPayload The migration payload used to infer the migrator type
|
||||||
*/
|
*/
|
||||||
public function create(string $migrationPayload) : Migrator
|
public function create(string $migrationPayload) : Migrator
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ class MigratorFactory implements MigratorFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Determine if a payload comes from Google Authenticator
|
* Determine if a payload comes from Google Authenticator
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload The payload to analyse
|
* @param string $migrationPayload The payload to analyse
|
||||||
*/
|
*/
|
||||||
private function isGoogleAuth(string $migrationPayload) : bool
|
private function isGoogleAuth(string $migrationPayload) : bool
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ class MigratorFactory implements MigratorFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Determine if a payload is a plain text content
|
* Determine if a payload is a plain text content
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload The payload to analyse
|
* @param string $migrationPayload The payload to analyse
|
||||||
*/
|
*/
|
||||||
private function isPlainText(string $migrationPayload) : bool
|
private function isPlainText(string $migrationPayload) : bool
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ class MigratorFactory implements MigratorFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Determine if a payload comes from 2FAuth in JSON format
|
* Determine if a payload comes from 2FAuth in JSON format
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload The payload to analyse
|
* @param string $migrationPayload The payload to analyse
|
||||||
*/
|
*/
|
||||||
private function isTwoFAuthJSON(string $migrationPayload) : bool
|
private function isTwoFAuthJSON(string $migrationPayload) : bool
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ class MigratorFactory implements MigratorFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Determine if a payload comes from Aegis Authenticator in JSON format
|
* Determine if a payload comes from Aegis Authenticator in JSON format
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload The payload to analyse
|
* @param string $migrationPayload The payload to analyse
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isAegisJSON(string $migrationPayload) : mixed
|
private function isAegisJSON(string $migrationPayload) : mixed
|
||||||
@ -150,7 +150,7 @@ class MigratorFactory implements MigratorFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Determine if a payload comes from 2FAS Authenticator
|
* Determine if a payload comes from 2FAS Authenticator
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload The payload to analyse
|
* @param string $migrationPayload The payload to analyse
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function is2FASv2(string $migrationPayload) : mixed
|
private function is2FASv2(string $migrationPayload) : mixed
|
||||||
|
@ -9,7 +9,7 @@ interface MigratorFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Infer the type of migrator needed from a payload and create the migrator
|
* Infer the type of migrator needed from a payload and create the migrator
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload The migration payload used to infer the migrator type
|
* @param string $migrationPayload The migration payload used to infer the migrator type
|
||||||
*/
|
*/
|
||||||
public function create(string $migrationPayload) : Migrator;
|
public function create(string $migrationPayload) : Migrator;
|
||||||
}
|
}
|
||||||
|
@ -27,14 +27,14 @@ class Group extends Model
|
|||||||
/**
|
/**
|
||||||
* model's array form.
|
* model's array form.
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['name'];
|
protected $fillable = ['name'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The accessors to append to the model's array form.
|
* The accessors to append to the model's array form.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $appends = [];
|
protected $appends = [];
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class Option extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'key',
|
'key',
|
||||||
|
@ -95,7 +95,7 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
/**
|
/**
|
||||||
* model's array form.
|
* model's array form.
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
// 'service',
|
// 'service',
|
||||||
@ -119,7 +119,7 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
/**
|
/**
|
||||||
* The accessors to append to the model's array form.
|
* The accessors to append to the model's array form.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
public $appends = [];
|
public $appends = [];
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
* Store and set the provided icon
|
* Store and set the provided icon
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $data
|
* @param \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $data
|
||||||
* @param string|null $extension The resource extension, without the dot
|
* @param string|null $extension The resource extension, without the dot
|
||||||
*/
|
*/
|
||||||
public function setIcon($data, $extension = null) : void
|
public function setIcon($data, $extension = null) : void
|
||||||
{
|
{
|
||||||
@ -633,7 +633,7 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
* Store img data as an icon file.
|
* Store img data as an icon file.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $content
|
* @param \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $content
|
||||||
* @param string $extension The file extension, without the dot
|
* @param string $extension The file extension, without the dot
|
||||||
* @return string|null The filename of the stored icon or null if the operation fails
|
* @return string|null The filename of the stored icon or null if the operation fails
|
||||||
*/
|
*/
|
||||||
private function storeFileDataAsIcon($content, $extension) : ?string
|
private function storeFileDataAsIcon($content, $extension) : ?string
|
||||||
|
@ -46,15 +46,9 @@ use Laravel\Passport\HasApiTokens;
|
|||||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Bubka\LaravelAuthenticationLog\Models\AuthenticationLog> $authentications
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Bubka\LaravelAuthenticationLog\Models\AuthenticationLog> $authentications
|
||||||
* @property-read int|null $authentications_count
|
* @property-read int|null $authentications_count
|
||||||
* @property-read \Bubka\LaravelAuthenticationLog\Models\AuthenticationLog|null $latestAuthentication
|
* @property-read \Bubka\LaravelAuthenticationLog\Models\AuthenticationLog|null $latestAuthentication
|
||||||
|
*
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|User admins()
|
* @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
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable
|
class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable
|
||||||
@ -66,7 +60,7 @@ class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthe
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var array<int,string>
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name', 'email', 'password', 'oauth_id', 'oauth_provider',
|
'name', 'email', 'password', 'oauth_id', 'oauth_provider',
|
||||||
@ -148,15 +142,13 @@ class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthe
|
|||||||
/**
|
/**
|
||||||
* Say if the user is the only registered administrator
|
* Say if the user is the only registered administrator
|
||||||
*
|
*
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isLastAdministrator()
|
public function isLastAdministrator()
|
||||||
{
|
{
|
||||||
$admins = User::admins()->get();
|
$admins = User::admins()->get();
|
||||||
|
|
||||||
$toto = $admins->contains($this->id) && $admins->count() === 1;
|
return $admins->contains($this->id) && $admins->count() === 1;
|
||||||
|
|
||||||
return $toto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Bubka\LaravelAuthenticationLog\Models\AuthenticationLog;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Jenssegers\Agent\Agent;
|
use Jenssegers\Agent\Agent;
|
||||||
use Bubka\LaravelAuthenticationLog\Models\AuthenticationLog;
|
|
||||||
|
|
||||||
class SignedInWithNewDevice extends Notification implements ShouldQueue
|
class SignedInWithNewDevice extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
@ -32,10 +32,7 @@ class SignedInWithNewDevice extends Notification implements ShouldQueue
|
|||||||
$this->agent->setUserAgent($authenticationLog->user_agent);
|
$this->agent->setUserAgent($authenticationLog->user_agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function via(mixed $notifiable) : array|string
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function via($notifiable)
|
|
||||||
{
|
{
|
||||||
return $notifiable->notifyAuthenticationLogVia();
|
return $notifiable->notifyAuthenticationLogVia();
|
||||||
}
|
}
|
||||||
@ -43,7 +40,7 @@ class SignedInWithNewDevice extends Notification implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Wrap the notification to a mail envelop
|
* Wrap the notification to a mail envelop
|
||||||
*/
|
*/
|
||||||
public function toMail($notifiable)
|
public function toMail(mixed $notifiable) : MailMessage
|
||||||
{
|
{
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
||||||
->subject(__('notifications.new_device.subject'))
|
->subject(__('notifications.new_device.subject'))
|
||||||
|
@ -58,7 +58,7 @@ class OpenId extends AbstractProvider
|
|||||||
*/
|
*/
|
||||||
public function refreshToken($refreshToken)
|
public function refreshToken($refreshToken)
|
||||||
{
|
{
|
||||||
return $this->getHttpClient()->post($this->getTokenUrl(), [
|
return $this->getHttpClient()->post($this->getTokenUrl(), [/** @phpstan-ignore-line */
|
||||||
RequestOptions::FORM_PARAMS => [
|
RequestOptions::FORM_PARAMS => [
|
||||||
'client_id' => $this->clientId,
|
'client_id' => $this->clientId,
|
||||||
'client_secret' => $this->clientSecret,
|
'client_secret' => $this->clientSecret,
|
||||||
|
@ -14,8 +14,8 @@ class GroupService
|
|||||||
/**
|
/**
|
||||||
* Assign one or more accounts to a group
|
* Assign one or more accounts to a group
|
||||||
*
|
*
|
||||||
* @param array|int $ids accounts ids to assign
|
* @param array|int $ids accounts ids to assign
|
||||||
* @param \App\Models\Group|null $group The group the accounts will be assigned to
|
* @param \App\Models\Group|null $group The group the accounts will be assigned to
|
||||||
*
|
*
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,7 @@ class LogoService
|
|||||||
/**
|
/**
|
||||||
* Fetch a logo for the given service and save it as an icon
|
* Fetch a logo for the given service and save it as an icon
|
||||||
*
|
*
|
||||||
* @param string $serviceName Name of the service to fetch a logo for
|
* @param string $serviceName Name of the service to fetch a logo for
|
||||||
* @return string|null The icon filename or null if no logo has been found
|
* @return string|null The icon filename or null if no logo has been found
|
||||||
*/
|
*/
|
||||||
public function getIcon($serviceName)
|
public function getIcon($serviceName)
|
||||||
@ -52,7 +52,7 @@ class LogoService
|
|||||||
/**
|
/**
|
||||||
* Return the logo's filename for a given service
|
* Return the logo's filename for a given service
|
||||||
*
|
*
|
||||||
* @param string $serviceName Name of the service to fetch a logo for
|
* @param string $serviceName Name of the service to fetch a logo for
|
||||||
* @return string|null The logo filename or null if no logo has been found
|
* @return string|null The logo filename or null if no logo has been found
|
||||||
*/
|
*/
|
||||||
protected function getLogo($serviceName)
|
protected function getLogo($serviceName)
|
||||||
@ -114,7 +114,7 @@ class LogoService
|
|||||||
/**
|
/**
|
||||||
* Fetch and cache a logo from 2fa.Directory repository
|
* Fetch and cache a logo from 2fa.Directory repository
|
||||||
*
|
*
|
||||||
* @param string $logoFile Logo filename to fetch
|
* @param string $logoFile Logo filename to fetch
|
||||||
*/
|
*/
|
||||||
protected function fetchLogo(string $logoFile) : void
|
protected function fetchLogo(string $logoFile) : void
|
||||||
{
|
{
|
||||||
|
@ -20,13 +20,13 @@ class GoogleAuthMigrator extends Migrator
|
|||||||
/**
|
/**
|
||||||
* Convert Google Authenticator migration URI to a set of TwoFAccount objects.
|
* Convert Google Authenticator migration URI to a set of TwoFAccount objects.
|
||||||
*
|
*
|
||||||
* @param mixed $migrationPayload migration uri provided by Google Authenticator export feature
|
* @param mixed $migrationPayload migration uri provided by Google Authenticator export feature
|
||||||
* @return \Illuminate\Support\Collection<int|string, \App\Models\TwoFAccount> The converted accounts
|
* @return \Illuminate\Support\Collection<int|string, \App\Models\TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
public function migrate(mixed $migrationPayload) : Collection
|
public function migrate(mixed $migrationPayload) : Collection
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$migrationData = base64_decode(urldecode(Str::replace('otpauth-migration://offline?data=', '', $migrationPayload)));
|
$migrationData = base64_decode(urldecode(Str::replace('otpauth-migration://offline?data=', '', strval($migrationPayload))));
|
||||||
$protobuf = new Payload();
|
$protobuf = new Payload();
|
||||||
$protobuf->mergeFromString($migrationData);
|
$protobuf->mergeFromString($migrationData);
|
||||||
$otpParameters = $protobuf->getOtpParameters();
|
$otpParameters = $protobuf->getOtpParameters();
|
||||||
|
@ -15,7 +15,7 @@ class QrCodeService
|
|||||||
/**
|
/**
|
||||||
* Encode a string into a QR code image
|
* Encode a string into a QR code image
|
||||||
*
|
*
|
||||||
* @param string $data The string to encode
|
* @param string $data The string to encode
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function encode(string $data)
|
public static function encode(string $data)
|
||||||
@ -55,19 +55,12 @@ class QrCodeService
|
|||||||
switch (get_class($qrcode->getError())) {
|
switch (get_class($qrcode->getError())) {
|
||||||
case NotFoundException::class:
|
case NotFoundException::class:
|
||||||
throw new \App\Exceptions\InvalidQrCodeException(__('errors.cannot_detect_qrcode_in_image'));
|
throw new \App\Exceptions\InvalidQrCodeException(__('errors.cannot_detect_qrcode_in_image'));
|
||||||
break;
|
|
||||||
|
|
||||||
case FormatException::class:
|
case FormatException::class:
|
||||||
throw new \App\Exceptions\InvalidQrCodeException(__('errors.cannot_decode_detected_qrcode'));
|
throw new \App\Exceptions\InvalidQrCodeException(__('errors.cannot_decode_detected_qrcode'));
|
||||||
break;
|
|
||||||
|
|
||||||
case ChecksumException::class:
|
case ChecksumException::class:
|
||||||
throw new \App\Exceptions\InvalidQrCodeException(__('errors.qrcode_has_invalid_checksum'));
|
throw new \App\Exceptions\InvalidQrCodeException(__('errors.qrcode_has_invalid_checksum'));
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \App\Exceptions\InvalidQrCodeException(__('errors.no_readable_qrcode'));
|
throw new \App\Exceptions\InvalidQrCodeException(__('errors.no_readable_qrcode'));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class SettingService
|
|||||||
/**
|
/**
|
||||||
* Get a setting
|
* Get a setting
|
||||||
*
|
*
|
||||||
* @param string $setting A single setting name
|
* @param string $setting A single setting name
|
||||||
* @return mixed string|int|boolean|null
|
* @return mixed string|int|boolean|null
|
||||||
*/
|
*/
|
||||||
public function get($setting)
|
public function get($setting)
|
||||||
@ -67,8 +67,8 @@ class SettingService
|
|||||||
/**
|
/**
|
||||||
* Set a setting
|
* Set a setting
|
||||||
*
|
*
|
||||||
* @param string|array $setting A single setting name or an associative array of name:value settings
|
* @param string|array $setting A single setting name or an associative array of name:value settings
|
||||||
* @param string|int|bool|null $value The value for single setting
|
* @param string|int|bool|null $value The value for single setting
|
||||||
*/
|
*/
|
||||||
public function set($setting, $value = null) : void
|
public function set($setting, $value = null) : void
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ class SettingService
|
|||||||
/**
|
/**
|
||||||
* Delete a setting
|
* Delete a setting
|
||||||
*
|
*
|
||||||
* @param string $name The setting name
|
* @param string $name The setting name
|
||||||
*/
|
*/
|
||||||
public function delete(string $name) : void
|
public function delete(string $name) : void
|
||||||
{
|
{
|
||||||
@ -200,7 +200,7 @@ class SettingService
|
|||||||
/**
|
/**
|
||||||
* Encrypt/Decrypt accounts in database
|
* Encrypt/Decrypt accounts in database
|
||||||
*
|
*
|
||||||
* @param bool $encrypted Whether the record should be encrypted or not
|
* @param bool $encrypted Whether the record should be encrypted or not
|
||||||
* @return bool Whether the operation completed successfully
|
* @return bool Whether the operation completed successfully
|
||||||
*/
|
*/
|
||||||
private function updateRecords(bool $encrypted) : bool
|
private function updateRecords(bool $encrypted) : bool
|
||||||
|
@ -28,7 +28,7 @@ class TwoFAccountService
|
|||||||
/**
|
/**
|
||||||
* Withdraw one or more twofaccounts from their group
|
* Withdraw one or more twofaccounts from their group
|
||||||
*
|
*
|
||||||
* @param int|array|string $ids twofaccount ids to free
|
* @param int|array|string $ids twofaccount ids to free
|
||||||
*/
|
*/
|
||||||
public static function withdraw($ids) : void
|
public static function withdraw($ids) : void
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ class TwoFAccountService
|
|||||||
/**
|
/**
|
||||||
* Convert a migration payload to a set of TwoFAccount objects
|
* Convert a migration payload to a set of TwoFAccount objects
|
||||||
*
|
*
|
||||||
* @param string $migrationPayload Migration payload from 2FA apps export feature
|
* @param string $migrationPayload Migration payload from 2FA apps export feature
|
||||||
* @return \Illuminate\Support\Collection<int|string, TwoFAccount> The converted accounts
|
* @return \Illuminate\Support\Collection<int|string, TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
public function migrate(string $migrationPayload) : Collection
|
public function migrate(string $migrationPayload) : Collection
|
||||||
@ -64,7 +64,7 @@ class TwoFAccountService
|
|||||||
/**
|
/**
|
||||||
* Export one or more twofaccounts
|
* Export one or more twofaccounts
|
||||||
*
|
*
|
||||||
* @param int|array|string $ids twofaccount ids to delete
|
* @param int|array|string $ids twofaccount ids to delete
|
||||||
* @return \Illuminate\Support\Collection<int, TwoFAccount> The converted accounts
|
* @return \Illuminate\Support\Collection<int, TwoFAccount> The converted accounts
|
||||||
*/
|
*/
|
||||||
public static function export($ids) : Collection
|
public static function export($ids) : Collection
|
||||||
@ -80,7 +80,7 @@ class TwoFAccountService
|
|||||||
/**
|
/**
|
||||||
* Delete one or more twofaccounts
|
* Delete one or more twofaccounts
|
||||||
*
|
*
|
||||||
* @param int|array|string $ids twofaccount ids to delete
|
* @param int|array|string $ids twofaccount ids to delete
|
||||||
* @return int The number of deleted
|
* @return int The number of deleted
|
||||||
*/
|
*/
|
||||||
public static function delete($ids) : int
|
public static function delete($ids) : int
|
||||||
|
@ -589,7 +589,7 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
'logout_at',
|
'logout_at',
|
||||||
'login_successful',
|
'login_successful',
|
||||||
'duration',
|
'duration',
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
||||||
->assertJsonCount(1)
|
->assertJsonCount(1)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => null
|
'login_at' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,7 +619,7 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
||||||
->assertJsonCount(1)
|
->assertJsonCount(1)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'logout_at' => null
|
'logout_at' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,7 +635,7 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
||||||
->assertJsonCount(1)
|
->assertJsonCount(1)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expected,
|
'login_at' => $expected,
|
||||||
'login_successful' => false,
|
'login_successful' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -652,7 +652,7 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
||||||
->assertJsonCount(3)
|
->assertJsonCount(3)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expected
|
'login_at' => $expected,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,17 +662,17 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
public function test_authentications_returns_last_three_months_entries() : void
|
public function test_authentications_returns_last_three_months_entries() : void
|
||||||
{
|
{
|
||||||
$this->feedAuthenticationLog();
|
$this->feedAuthenticationLog();
|
||||||
$expectedOneMonth = Carbon::parse(AuthenticationLogData::duringLastMonth()['login_at'])->toDayDateTimeString();
|
$expectedOneMonth = Carbon::parse(AuthenticationLogData::duringLastMonth()['login_at'])->toDayDateTimeString();
|
||||||
$expectedThreeMonth = Carbon::parse(AuthenticationLogData::duringLastThreeMonth()['login_at'])->toDayDateTimeString();
|
$expectedThreeMonth = Carbon::parse(AuthenticationLogData::duringLastThreeMonth()['login_at'])->toDayDateTimeString();
|
||||||
|
|
||||||
$this->actingAs($this->admin, 'api-guard')
|
$this->actingAs($this->admin, 'api-guard')
|
||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=3')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=3')
|
||||||
->assertJsonCount(4)
|
->assertJsonCount(4)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedOneMonth
|
'login_at' => $expectedOneMonth,
|
||||||
])
|
])
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedThreeMonth
|
'login_at' => $expectedThreeMonth,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,21 +682,21 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
public function test_authentications_returns_last_six_months_entries() : void
|
public function test_authentications_returns_last_six_months_entries() : void
|
||||||
{
|
{
|
||||||
$this->feedAuthenticationLog();
|
$this->feedAuthenticationLog();
|
||||||
$expectedOneMonth = Carbon::parse(AuthenticationLogData::duringLastMonth()['login_at'])->toDayDateTimeString();
|
$expectedOneMonth = Carbon::parse(AuthenticationLogData::duringLastMonth()['login_at'])->toDayDateTimeString();
|
||||||
$expectedThreeMonth = Carbon::parse(AuthenticationLogData::duringLastThreeMonth()['login_at'])->toDayDateTimeString();
|
$expectedThreeMonth = Carbon::parse(AuthenticationLogData::duringLastThreeMonth()['login_at'])->toDayDateTimeString();
|
||||||
$expectedSixMonth = Carbon::parse(AuthenticationLogData::duringLastSixMonth()['login_at'])->toDayDateTimeString();
|
$expectedSixMonth = Carbon::parse(AuthenticationLogData::duringLastSixMonth()['login_at'])->toDayDateTimeString();
|
||||||
|
|
||||||
$this->actingAs($this->admin, 'api-guard')
|
$this->actingAs($this->admin, 'api-guard')
|
||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=6')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=6')
|
||||||
->assertJsonCount(5)
|
->assertJsonCount(5)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedOneMonth
|
'login_at' => $expectedOneMonth,
|
||||||
])
|
])
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedThreeMonth
|
'login_at' => $expectedThreeMonth,
|
||||||
])
|
])
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedSixMonth
|
'login_at' => $expectedSixMonth,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,25 +706,25 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
public function test_authentications_returns_last_year_entries() : void
|
public function test_authentications_returns_last_year_entries() : void
|
||||||
{
|
{
|
||||||
$this->feedAuthenticationLog();
|
$this->feedAuthenticationLog();
|
||||||
$expectedOneMonth = Carbon::parse(AuthenticationLogData::duringLastMonth()['login_at'])->toDayDateTimeString();
|
$expectedOneMonth = Carbon::parse(AuthenticationLogData::duringLastMonth()['login_at'])->toDayDateTimeString();
|
||||||
$expectedThreeMonth = Carbon::parse(AuthenticationLogData::duringLastThreeMonth()['login_at'])->toDayDateTimeString();
|
$expectedThreeMonth = Carbon::parse(AuthenticationLogData::duringLastThreeMonth()['login_at'])->toDayDateTimeString();
|
||||||
$expectedSixMonth = Carbon::parse(AuthenticationLogData::duringLastSixMonth()['login_at'])->toDayDateTimeString();
|
$expectedSixMonth = Carbon::parse(AuthenticationLogData::duringLastSixMonth()['login_at'])->toDayDateTimeString();
|
||||||
$expectedYear = Carbon::parse(AuthenticationLogData::duringLastYear()['login_at'])->toDayDateTimeString();
|
$expectedYear = Carbon::parse(AuthenticationLogData::duringLastYear()['login_at'])->toDayDateTimeString();
|
||||||
|
|
||||||
$this->actingAs($this->admin, 'api-guard')
|
$this->actingAs($this->admin, 'api-guard')
|
||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=12')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=12')
|
||||||
->assertJsonCount(6)
|
->assertJsonCount(6)
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedOneMonth
|
'login_at' => $expectedOneMonth,
|
||||||
])
|
])
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedThreeMonth
|
'login_at' => $expectedThreeMonth,
|
||||||
])
|
])
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedSixMonth
|
'login_at' => $expectedSixMonth,
|
||||||
])
|
])
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'login_at' => $expectedYear
|
'login_at' => $expectedYear,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,21 +760,21 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
public function test_authentications_returns_expected_ip_and_useragent_chunks() : void
|
public function test_authentications_returns_expected_ip_and_useragent_chunks() : void
|
||||||
{
|
{
|
||||||
$this->user->authentications()->create([
|
$this->user->authentications()->create([
|
||||||
'ip_address' => '127.0.0.1',
|
'ip_address' => '127.0.0.1',
|
||||||
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
|
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
|
||||||
'login_at' => now(),
|
'login_at' => now(),
|
||||||
'login_successful' => true,
|
'login_successful' => true,
|
||||||
'logout_at' => null,
|
'logout_at' => null,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->actingAs($this->admin, 'api-guard')
|
$this->actingAs($this->admin, 'api-guard')
|
||||||
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
->json('GET', '/api/v1/users/' . $this->user->id . '/authentications?period=1')
|
||||||
->assertJsonFragment([
|
->assertJsonFragment([
|
||||||
'ip_address' => '127.0.0.1',
|
'ip_address' => '127.0.0.1',
|
||||||
'browser' => 'Firefox',
|
'browser' => 'Firefox',
|
||||||
'platform' => 'Windows',
|
'platform' => 'Windows',
|
||||||
'device' => 'desktop',
|
'device' => 'desktop',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -806,12 +806,11 @@ class UserManagerControllerTest extends FeatureTestCase
|
|||||||
public static function invalidQueryParameterProvider()
|
public static function invalidQueryParameterProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'empty' => [''],
|
'empty' => [''],
|
||||||
'null' => ['null'],
|
'null' => ['null'],
|
||||||
'boolean' => ['true'],
|
'boolean' => ['true'],
|
||||||
'string' => ['string'],
|
'string' => ['string'],
|
||||||
'array' => ['[]'],
|
'array' => ['[]'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,12 @@ class AuthenticationLogData
|
|||||||
$loginDate = now()->subDays(15);
|
$loginDate = now()->subDays(15);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ip_address' => fake()->ipv4(),
|
'ip_address' => fake()->ipv4(),
|
||||||
'user_agent' => fake()->userAgent(),
|
'user_agent' => fake()->userAgent(),
|
||||||
'login_at' => $loginDate,
|
'login_at' => $loginDate,
|
||||||
'login_successful' => false,
|
'login_successful' => false,
|
||||||
'logout_at' => null,
|
'logout_at' => null,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ class AuthenticationLogData
|
|||||||
public static function noLogin()
|
public static function noLogin()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'ip_address' => fake()->ipv4(),
|
'ip_address' => fake()->ipv4(),
|
||||||
'user_agent' => fake()->userAgent(),
|
'user_agent' => fake()->userAgent(),
|
||||||
'login_at' => null,
|
'login_at' => null,
|
||||||
'login_successful' => false,
|
'login_successful' => false,
|
||||||
'logout_at' => now(),
|
'logout_at' => now(),
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,12 +48,12 @@ class AuthenticationLogData
|
|||||||
public static function noLogout()
|
public static function noLogout()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'ip_address' => fake()->ipv4(),
|
'ip_address' => fake()->ipv4(),
|
||||||
'user_agent' => fake()->userAgent(),
|
'user_agent' => fake()->userAgent(),
|
||||||
'login_at' => now(),
|
'login_at' => now(),
|
||||||
'login_successful' => true,
|
'login_successful' => true,
|
||||||
'logout_at' => null,
|
'logout_at' => null,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,16 +64,16 @@ class AuthenticationLogData
|
|||||||
*/
|
*/
|
||||||
public static function duringLastMonth()
|
public static function duringLastMonth()
|
||||||
{
|
{
|
||||||
$loginDate = now()->subDays(15);
|
$loginDate = now()->subDays(15);
|
||||||
$logoutDate = $loginDate->addHours(1);
|
$logoutDate = $loginDate->addHours(1);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ip_address' => '127.0.0.1',
|
'ip_address' => '127.0.0.1',
|
||||||
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
|
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
|
||||||
'login_at' => $loginDate,
|
'login_at' => $loginDate,
|
||||||
'login_successful' => true,
|
'login_successful' => true,
|
||||||
'logout_at' => $logoutDate,
|
'logout_at' => $logoutDate,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,16 +84,16 @@ class AuthenticationLogData
|
|||||||
*/
|
*/
|
||||||
public static function duringLastThreeMonth()
|
public static function duringLastThreeMonth()
|
||||||
{
|
{
|
||||||
$loginDate = now()->subMonths(2);
|
$loginDate = now()->subMonths(2);
|
||||||
$logoutDate = $loginDate->addHours(1);
|
$logoutDate = $loginDate->addHours(1);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ip_address' => fake()->ipv4(),
|
'ip_address' => fake()->ipv4(),
|
||||||
'user_agent' => fake()->userAgent(),
|
'user_agent' => fake()->userAgent(),
|
||||||
'login_at' => $loginDate,
|
'login_at' => $loginDate,
|
||||||
'login_successful' => true,
|
'login_successful' => true,
|
||||||
'logout_at' => $logoutDate,
|
'logout_at' => $logoutDate,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,16 +104,16 @@ class AuthenticationLogData
|
|||||||
*/
|
*/
|
||||||
public static function duringLastSixMonth()
|
public static function duringLastSixMonth()
|
||||||
{
|
{
|
||||||
$loginDate = now()->subMonths(4);
|
$loginDate = now()->subMonths(4);
|
||||||
$logoutDate = $loginDate->addHours(1);
|
$logoutDate = $loginDate->addHours(1);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ip_address' => fake()->ipv4(),
|
'ip_address' => fake()->ipv4(),
|
||||||
'user_agent' => fake()->userAgent(),
|
'user_agent' => fake()->userAgent(),
|
||||||
'login_at' => $loginDate,
|
'login_at' => $loginDate,
|
||||||
'login_successful' => true,
|
'login_successful' => true,
|
||||||
'logout_at' => $logoutDate,
|
'logout_at' => $logoutDate,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,16 +124,16 @@ class AuthenticationLogData
|
|||||||
*/
|
*/
|
||||||
public static function duringLastYear()
|
public static function duringLastYear()
|
||||||
{
|
{
|
||||||
$loginDate = now()->subMonths(10);
|
$loginDate = now()->subMonths(10);
|
||||||
$logoutDate = $loginDate->addHours(1);
|
$logoutDate = $loginDate->addHours(1);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ip_address' => fake()->ipv4(),
|
'ip_address' => fake()->ipv4(),
|
||||||
'user_agent' => fake()->userAgent(),
|
'user_agent' => fake()->userAgent(),
|
||||||
'login_at' => $loginDate,
|
'login_at' => $loginDate,
|
||||||
'login_successful' => true,
|
'login_successful' => true,
|
||||||
'logout_at' => $logoutDate,
|
'logout_at' => $logoutDate,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,16 +144,16 @@ class AuthenticationLogData
|
|||||||
*/
|
*/
|
||||||
public static function beforeLastYear()
|
public static function beforeLastYear()
|
||||||
{
|
{
|
||||||
$loginDate = now()->subYears(2);
|
$loginDate = now()->subYears(2);
|
||||||
$logoutDate = $loginDate->addHours(1);
|
$logoutDate = $loginDate->addHours(1);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ip_address' => fake()->ipv4(),
|
'ip_address' => fake()->ipv4(),
|
||||||
'user_agent' => fake()->userAgent(),
|
'user_agent' => fake()->userAgent(),
|
||||||
'login_at' => $loginDate,
|
'login_at' => $loginDate,
|
||||||
'login_successful' => true,
|
'login_successful' => true,
|
||||||
'logout_at' => $logoutDate,
|
'logout_at' => $logoutDate,
|
||||||
'location' => null,
|
'location' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user