mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-03-15 07:28:30 +01:00
Fix phpstan issues
This commit is contained in:
parent
d4a06167e5
commit
18fe45778a
@ -24,13 +24,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\AuthLogFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $authenticatable_type
|
||||
* @property int $authenticatable_id
|
||||
@ -44,11 +43,14 @@
|
||||
* @property string|null $method
|
||||
* @property string|null $login_method
|
||||
* @property-read Model|\Eloquent $authenticatable
|
||||
*
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class AuthLog extends Model
|
||||
{
|
||||
/**
|
||||
* @use HasFactory<AuthLogFactory>
|
||||
*/
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Events\GroupDeleted;
|
||||
use App\Events\GroupDeleting;
|
||||
use Database\Factories\GroupFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -19,7 +20,7 @@
|
||||
* @property int|null $user_id
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TwoFAccount[] $twofaccounts
|
||||
* @property-read \App\Models\User|null $user
|
||||
*
|
||||
*
|
||||
* @method static \Database\Factories\GroupFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Group newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Group newQuery()
|
||||
@ -29,11 +30,14 @@
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Group whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Group whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Group whereUserId($value)
|
||||
*
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Group extends Model
|
||||
{
|
||||
/**
|
||||
* @use HasFactory<GroupFactory>
|
||||
*/
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
@ -127,5 +131,4 @@ public function scopeOrphans($query)
|
||||
{
|
||||
return $query->where('user_id', null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
use App\Models\Dto\HotpDto;
|
||||
use App\Models\Dto\TotpDto;
|
||||
use App\Services\LogoService;
|
||||
use Database\Factories\TwoFAccountFactory;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -53,7 +54,7 @@
|
||||
* @property int|null $counter
|
||||
* @property int|null $user_id
|
||||
* @property-read \App\Models\User|null $user
|
||||
*
|
||||
*
|
||||
* @method static \Database\Factories\TwoFAccountFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TwoFAccount newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TwoFAccount newQuery()
|
||||
@ -75,12 +76,17 @@
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TwoFAccount whereService($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TwoFAccount whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TwoFAccount whereUserId($value)
|
||||
*
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TwoFAccount extends Model implements Sortable
|
||||
{
|
||||
use HasFactory, SortableTrait;
|
||||
/**
|
||||
* @use HasFactory<TwoFAccountFactory>
|
||||
*/
|
||||
use HasFactory;
|
||||
|
||||
use SortableTrait;
|
||||
|
||||
const TOTP = 'totp';
|
||||
|
||||
@ -407,14 +413,14 @@ public function getOTP(?int $time = null)
|
||||
if (strtolower($this->secret) === __('errors.indecipherable')) {
|
||||
Log::error('Secret cannot be deciphered, OTP generation aborted');
|
||||
|
||||
throw new UndecipherableException();
|
||||
throw new UndecipherableException;
|
||||
}
|
||||
|
||||
$this->initGenerator();
|
||||
|
||||
try {
|
||||
if ($this->otp_type === self::HOTP) {
|
||||
$OtpDto = new HotpDto();
|
||||
$OtpDto = new HotpDto;
|
||||
$OtpDto->otp_type = $this->otp_type;
|
||||
$counter = $this->generator->getParameter('counter');
|
||||
$OtpDto->password = $this->generator->at($counter);
|
||||
@ -425,7 +431,7 @@ public function getOTP(?int $time = null)
|
||||
$this->save();
|
||||
}
|
||||
} else {
|
||||
$OtpDto = new TotpDto();
|
||||
$OtpDto = new TotpDto;
|
||||
$OtpDto->otp_type = $this->otp_type;
|
||||
$OtpDto->generated_at = $time ?: time();
|
||||
$OtpDto->password = $this->otp_type === self::TOTP
|
||||
@ -637,7 +643,7 @@ private function initGenerator() : void
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnsupportedOtpTypeException();
|
||||
throw new UnsupportedOtpTypeException;
|
||||
}
|
||||
|
||||
if ($this->service) {
|
||||
@ -799,6 +805,7 @@ private function decryptOrReturn(mixed $value) : mixed
|
||||
return Crypt::decryptString($value);
|
||||
} catch (Exception $ex) {
|
||||
Log::debug(sprintf('Service field of twofaccount with id #%s cannot be deciphered', $this->id));
|
||||
|
||||
return __('errors.indecipherable');
|
||||
}
|
||||
} else {
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Models\Traits\HasAuthenticationLog;
|
||||
use App\Models\Traits\WebAuthnManageCredentials;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||
@ -46,8 +47,8 @@
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\AuthLog> $authentications
|
||||
* @property-read int|null $authentications_count
|
||||
* @property-read \App\Models\AuthLog|null $latestAuthentication
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User admins()
|
||||
*
|
||||
* @method static \Database\Factories\UserFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
|
||||
@ -63,13 +64,18 @@
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User wherePreferences($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
|
||||
*
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
use HasApiTokens, Notifiable;
|
||||
|
||||
use HasAuthenticationLog;
|
||||
/**
|
||||
* @use HasFactory<UserFactory>
|
||||
*/
|
||||
use HasFactory;
|
||||
use WebAuthnAuthentication, WebAuthnManageCredentials;
|
||||
|
||||
/**
|
||||
@ -259,5 +265,4 @@ public function equals(self $other) : bool
|
||||
$this->oauth_id == $other->oauth_id &&
|
||||
$this->oauth_provider == $other->oauth_provider;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user