2019-05-20 07:37:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
2020-11-05 22:54:06 +01:00
|
|
|
use Exception;
|
2020-11-12 00:09:33 +01:00
|
|
|
use OTPHP\TOTP;
|
2020-01-24 12:56:38 +01:00
|
|
|
use OTPHP\HOTP;
|
|
|
|
use OTPHP\Factory;
|
2020-10-31 01:16:15 +01:00
|
|
|
use App\Classes\Options;
|
2020-11-17 21:27:44 +01:00
|
|
|
use ParagonIE\ConstantTime\Base32;
|
2020-03-25 21:58:05 +01:00
|
|
|
use Spatie\EloquentSortable\Sortable;
|
|
|
|
use Spatie\EloquentSortable\SortableTrait;
|
2019-05-20 07:37:41 +02:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2020-01-08 17:03:41 +01:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2020-10-31 01:16:15 +01:00
|
|
|
use Illuminate\Support\Facades\Crypt;
|
2019-05-20 07:37:41 +02:00
|
|
|
|
2020-03-25 21:58:05 +01:00
|
|
|
class TwoFAccount extends Model implements Sortable
|
2019-05-20 07:37:41 +02:00
|
|
|
{
|
2020-03-25 21:58:05 +01:00
|
|
|
|
|
|
|
use SortableTrait;
|
|
|
|
|
|
|
|
|
2020-01-10 13:43:36 +01:00
|
|
|
/**
|
|
|
|
* model's array form.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = ['service', 'account', 'uri', 'icon'];
|
2019-05-24 14:44:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The table associated with the model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $table = 'twofaccounts';
|
2020-01-08 17:03:41 +01:00
|
|
|
|
|
|
|
|
2020-01-24 12:56:38 +01:00
|
|
|
/**
|
|
|
|
* The accessors to append to the model's array form.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2020-11-16 09:38:28 +01:00
|
|
|
protected $appends = ['token', 'isConsistent', 'otpType', 'secret', 'algorithm', 'digits', 'totpPeriod', 'totpTimestamp', 'hotpCounter', 'imageLink'];
|
2020-01-24 12:56:38 +01:00
|
|
|
|
|
|
|
|
2020-11-06 15:51:52 +01:00
|
|
|
/**
|
|
|
|
* The attributes that should be hidden for arrays.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2020-11-21 21:46:31 +01:00
|
|
|
protected $hidden = ['token', 'uri', 'secret', 'algorithm', 'created_at', 'updated_at'];
|
2020-11-12 00:09:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An OTP object from package Spomky-Labs/otphp
|
|
|
|
*
|
|
|
|
* @var OTPHP/TOTP || OTPHP/HOTP
|
|
|
|
*/
|
2020-11-22 11:00:55 +01:00
|
|
|
protected $otp, $timestamp, $badUri;
|
2020-11-06 15:51:52 +01:00
|
|
|
|
|
|
|
|
2020-01-31 23:05:06 +01:00
|
|
|
/**
|
|
|
|
* Override The "booting" method of the model
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected static function boot()
|
|
|
|
{
|
|
|
|
parent::boot();
|
2020-11-12 00:09:33 +01:00
|
|
|
|
|
|
|
static::retrieved(function ($model) {
|
2020-11-22 11:00:55 +01:00
|
|
|
try {
|
|
|
|
$model->populateFromUri($model->uri);
|
|
|
|
}
|
|
|
|
catch( \App\Exceptions\InvalidOtpParameterException $e ) {
|
|
|
|
$model->badUri = true;
|
|
|
|
}
|
2020-11-12 00:09:33 +01:00
|
|
|
});
|
2020-11-14 18:43:30 +01:00
|
|
|
|
|
|
|
static::saving(function ($model) {
|
|
|
|
$model->refreshUri();
|
|
|
|
});
|
2020-01-31 23:05:06 +01:00
|
|
|
|
|
|
|
static::deleted(function ($model) {
|
|
|
|
Storage::delete('public/icons/' . $model->icon);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-25 23:51:50 +01:00
|
|
|
/**
|
|
|
|
* Scope a query to only include TwoFAccounts of a given group.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
|
|
* @param mixed $groupId
|
|
|
|
* @return \Illuminate\Database\Eloquent\Builder
|
|
|
|
*/
|
|
|
|
public function scopeOfGroup($query, $groupId)
|
|
|
|
{
|
|
|
|
if( $groupId ) {
|
|
|
|
return $query->where('group_id', $groupId);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-25 21:58:05 +01:00
|
|
|
/**
|
|
|
|
* Sortable settings
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $sortable = [
|
|
|
|
'order_column_name' => 'order_column',
|
|
|
|
'sort_when_creating' => true,
|
|
|
|
];
|
|
|
|
|
|
|
|
|
2020-01-08 17:03:41 +01:00
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* Populate attributes with direct values
|
|
|
|
* @param Array|array $attrib All attributes to be set
|
|
|
|
*/
|
|
|
|
public function populate(Array $attrib = [])
|
|
|
|
{
|
|
|
|
// The Type and Secret attributes are mandatory
|
|
|
|
// All other attributes have default value set by OTPHP
|
|
|
|
|
|
|
|
if( $attrib['otpType'] !== 'totp' && $attrib['otpType'] !== 'hotp' ) {
|
|
|
|
throw \Illuminate\Validation\ValidationException::withMessages([
|
|
|
|
'otpType' => __('errors.not_a_supported_otp_type')
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !$attrib['secret'] ) {
|
|
|
|
throw \Illuminate\Validation\ValidationException::withMessages([
|
|
|
|
'secret' => __('errors.cannot_create_otp_without_secret')
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Create an OTP object using our secret but with default parameters
|
|
|
|
$secret = $attrib['secretIsBase32Encoded'] === 1 ? $attrib['secret'] : Base32::encodeUpper($attrib['secret']);
|
|
|
|
|
|
|
|
$this->otp = $attrib['otpType'] === 'totp' ? TOTP::create($secret) : HOTP::create($secret);
|
|
|
|
|
|
|
|
// and we change parameters if needed
|
|
|
|
if (array_key_exists('service', $attrib) && $attrib['service']) {
|
|
|
|
$this->service = $attrib['service'];
|
|
|
|
$this->otp->setIssuer( $attrib['service'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_key_exists('account', $attrib) && $attrib['account']) {
|
|
|
|
$this->account = $attrib['account'];
|
|
|
|
$this->otp->setLabel( $attrib['account'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_key_exists('icon', $attrib) && $attrib['icon'])
|
|
|
|
{ $this->icon = $attrib['icon']; }
|
|
|
|
|
|
|
|
if (array_key_exists('digits', $attrib) && $attrib['digits'] > 0)
|
|
|
|
{ $this->otp->setParameter( 'digits', (int) $attrib['digits'] ); }
|
|
|
|
|
|
|
|
if (array_key_exists('algorithm', $attrib) && $attrib['algorithm'])
|
|
|
|
{ $this->otp->setParameter( 'algorithm', $attrib['algorithm'] ); }
|
|
|
|
|
|
|
|
if (array_key_exists('totpPeriod', $attrib) && $attrib['totpPeriod'] && $attrib['otpType'] === 'totp')
|
|
|
|
{ $this->otp->setParameter( 'period', (int) $attrib['totpPeriod'] ); }
|
|
|
|
|
|
|
|
if (array_key_exists('hotpCounter', $attrib) && $attrib['hotpCounter'] && $attrib['otpType'] === 'hotp')
|
|
|
|
{ $this->otp->setParameter( 'counter', (int) $attrib['hotpCounter'] ); }
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (\Exception $e) {
|
|
|
|
throw \Illuminate\Validation\ValidationException::withMessages([
|
|
|
|
'qrcode' => __('errors.cannot_create_otp_with_those_parameters')
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a token which is valid at the current time
|
|
|
|
* @return string The generated token
|
|
|
|
*/
|
|
|
|
public function generateToken() : string
|
|
|
|
{
|
|
|
|
$this->timestamp = time();
|
|
|
|
$token = $this->otpType === 'totp' ? $this->otp->at($this->timestamp) : $this->otp->at($this->otp->getCounter());
|
|
|
|
|
|
|
|
return $token;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increment the hotp counter by 1
|
|
|
|
* @return string The generated token
|
|
|
|
*/
|
|
|
|
public function increaseHotpCounter() : void
|
|
|
|
{
|
|
|
|
if( $this->otpType === 'hotp' ) {
|
|
|
|
$this->hotpCounter = $this->hotpCounter + 1;
|
|
|
|
$this->refreshUri();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Populate the OTP sub-object wih the model URI
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private function populateFromUri($uri)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
|
|
|
|
$this->otp = Factory::loadFromProvisioningUri($uri);
|
|
|
|
|
|
|
|
// Account and Service values should be already recorded in the db so we set them
|
|
|
|
// only when db has no value
|
|
|
|
if( !$this->service ) { $this->service = $this->otp->getIssuer(); }
|
|
|
|
if( !$this->account ) { $this->account = $this->otp->getLabel(); }
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (\Exception $e) {
|
2020-11-22 11:00:55 +01:00
|
|
|
throw new \App\Exceptions\InvalidOtpParameterException;
|
2020-11-18 01:13:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the uri attribute using the OTP object
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function refreshUri() : void
|
|
|
|
{
|
|
|
|
$this->uri = urldecode($this->otp->getProvisioningUri());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get icon attribute
|
2020-01-08 17:03:41 +01:00
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return string
|
2020-03-08 20:16:56 +01:00
|
|
|
*
|
|
|
|
* @codeCoverageIgnore
|
2020-01-08 17:03:41 +01:00
|
|
|
*/
|
|
|
|
public function getIconAttribute($value)
|
|
|
|
{
|
2020-11-18 01:13:00 +01:00
|
|
|
// Return an empty string if the corresponding resource does not exist on storage
|
2020-01-10 13:43:36 +01:00
|
|
|
if (\App::environment('testing') == false) {
|
2020-01-27 21:44:29 +01:00
|
|
|
if( !Storage::exists('public/icons/' . $value) ) {
|
2020-01-08 17:03:41 +01:00
|
|
|
|
2020-01-10 13:43:36 +01:00
|
|
|
return '';
|
|
|
|
}
|
2020-01-08 17:03:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
2020-01-21 21:31:28 +01:00
|
|
|
|
2020-01-27 13:52:47 +01:00
|
|
|
|
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* Icon attribute setter
|
2020-01-27 13:52:47 +01:00
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return string
|
2020-03-08 20:16:56 +01:00
|
|
|
*
|
|
|
|
* @codeCoverageIgnore
|
2020-01-27 13:52:47 +01:00
|
|
|
*/
|
|
|
|
public function setIconAttribute($value)
|
|
|
|
{
|
2020-11-18 01:13:00 +01:00
|
|
|
// Prevent setting a missing icon
|
2020-01-27 21:44:29 +01:00
|
|
|
if( !Storage::exists('public/icons/' . $value) && \App::environment('testing') == false ) {
|
2020-01-27 13:52:47 +01:00
|
|
|
|
|
|
|
$this->attributes['icon'] = '';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
$this->attributes['icon'] = $value;
|
|
|
|
}
|
|
|
|
}
|
2020-11-12 00:09:33 +01:00
|
|
|
|
2020-01-27 13:52:47 +01:00
|
|
|
|
2020-01-24 12:56:38 +01:00
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* Get uri attribute
|
2020-11-12 00:09:33 +01:00
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getUriAttribute($value)
|
2020-01-24 12:56:38 +01:00
|
|
|
{
|
2020-11-18 01:13:00 +01:00
|
|
|
// Decipher when needed
|
2020-11-12 00:09:33 +01:00
|
|
|
if( Options::get('useEncryption') )
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
return Crypt::decryptString($value);
|
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
return '*encrypted*';
|
|
|
|
}
|
2020-11-05 22:50:49 +01:00
|
|
|
}
|
2020-11-12 00:09:33 +01:00
|
|
|
else {
|
|
|
|
return $value;
|
2020-01-24 12:56:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-21 21:31:28 +01:00
|
|
|
/**
|
2020-11-17 15:30:50 +01:00
|
|
|
* Set uri attribute
|
2020-01-21 21:31:28 +01:00
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-10-31 01:16:15 +01:00
|
|
|
public function setUriAttribute($value)
|
|
|
|
{
|
2020-11-18 01:13:00 +01:00
|
|
|
// An uri contains all expected data to define an OTP object.
|
|
|
|
// So we populate the model instance at every uri definition
|
2020-11-17 15:30:50 +01:00
|
|
|
$this->populateFromUri($value);
|
2020-11-18 01:13:00 +01:00
|
|
|
|
|
|
|
// Encrypt if needed
|
2020-10-31 01:16:15 +01:00
|
|
|
$this->attributes['uri'] = Options::get('useEncryption') ? Crypt::encryptString($value) : $value;
|
|
|
|
}
|
2020-01-21 21:31:28 +01:00
|
|
|
|
2020-11-12 00:09:33 +01:00
|
|
|
|
2020-01-21 21:31:28 +01:00
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* Get account attribute
|
2020-01-21 21:31:28 +01:00
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return string
|
|
|
|
*/
|
2020-11-12 00:09:33 +01:00
|
|
|
public function getAccountAttribute($value)
|
2020-10-31 01:16:15 +01:00
|
|
|
{
|
2020-11-18 01:13:00 +01:00
|
|
|
// Decipher when needed
|
2020-10-31 01:16:15 +01:00
|
|
|
if( Options::get('useEncryption') )
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
return Crypt::decryptString($value);
|
|
|
|
}
|
2020-11-05 22:54:06 +01:00
|
|
|
catch (Exception $e) {
|
2020-10-31 01:16:15 +01:00
|
|
|
return '*encrypted*';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
}
|
2020-01-21 21:31:28 +01:00
|
|
|
|
|
|
|
|
2020-10-31 01:16:15 +01:00
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* Set account account
|
2020-10-31 01:16:15 +01:00
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setAccountAttribute($value)
|
|
|
|
{
|
2020-11-18 01:13:00 +01:00
|
|
|
// Encrypt when needed
|
2020-10-31 01:16:15 +01:00
|
|
|
$this->attributes['account'] = Options::get('useEncryption') ? Crypt::encryptString($value) : $value;
|
|
|
|
}
|
2020-01-21 21:31:28 +01:00
|
|
|
|
2020-11-12 00:09:33 +01:00
|
|
|
|
2020-10-31 01:16:15 +01:00
|
|
|
/**
|
2020-11-12 00:09:33 +01:00
|
|
|
* Get IsConsistent attribute
|
|
|
|
*
|
|
|
|
* @return bool
|
2020-10-31 01:16:15 +01:00
|
|
|
*
|
|
|
|
*/
|
2020-11-12 00:09:33 +01:00
|
|
|
public function getIsConsistentAttribute()
|
2020-10-31 01:16:15 +01:00
|
|
|
{
|
2020-11-22 11:00:55 +01:00
|
|
|
return $this->uri === '*encrypted*' || $this->account === '*encrypted*' || $this->badUri ? false : true;
|
2020-11-12 00:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 18:55:10 +01:00
|
|
|
/**
|
2020-11-16 09:38:28 +01:00
|
|
|
* get totpTimestamp attribute
|
2020-11-14 18:55:10 +01:00
|
|
|
*
|
2020-11-16 09:38:28 +01:00
|
|
|
* @return int The timestamp
|
2020-11-14 18:55:10 +01:00
|
|
|
*/
|
2020-11-16 09:38:28 +01:00
|
|
|
public function getTotpTimestampAttribute()
|
2020-11-14 18:55:10 +01:00
|
|
|
{
|
2020-11-16 09:38:28 +01:00
|
|
|
return $this->timestamp;
|
2020-11-14 18:55:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-16 09:38:28 +01:00
|
|
|
* get token attribute
|
2020-11-14 18:55:10 +01:00
|
|
|
*
|
2020-11-16 09:38:28 +01:00
|
|
|
* @return string The token
|
2020-11-14 18:55:10 +01:00
|
|
|
*/
|
2020-11-16 09:38:28 +01:00
|
|
|
public function getTokenAttribute() : string
|
2020-11-14 18:55:10 +01:00
|
|
|
{
|
2020-11-16 09:38:28 +01:00
|
|
|
return $this->generateToken();
|
2020-11-14 18:55:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 00:09:33 +01:00
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* get otpType attribute
|
2020-11-06 21:49:43 +01:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
2020-11-12 00:09:33 +01:00
|
|
|
public function getOtpTypeAttribute()
|
2020-11-06 21:49:43 +01:00
|
|
|
{
|
2020-11-22 11:00:55 +01:00
|
|
|
if( isset($this->otp) ) {
|
|
|
|
return get_class($this->otp) === 'OTPHP\TOTP' ? 'totp' : 'hotp';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return null;
|
|
|
|
}
|
2020-11-12 00:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get Secret attribute
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getSecretAttribute()
|
|
|
|
{
|
2020-11-22 11:00:55 +01:00
|
|
|
return isset($this->otp) ? $this->otp->getSecret() : null;
|
2020-11-12 00:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get algorithm attribute
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getAlgorithmAttribute()
|
|
|
|
{
|
2020-11-22 11:00:55 +01:00
|
|
|
return isset($this->otp) ? $this->otp->getDigest() : null; // default is SHA1
|
2020-11-12 00:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get Digits attribute
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getDigitsAttribute()
|
|
|
|
{
|
2020-11-22 11:00:55 +01:00
|
|
|
return isset($this->otp) ? $this->otp->getDigits() : null; // Default is 6
|
2020-11-12 00:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* get totpPeriod attribute
|
2020-11-12 00:09:33 +01:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getTotpPeriodAttribute()
|
|
|
|
{
|
|
|
|
return $this->otpType === 'totp' ? $this->otp->getPeriod() : null; // Default is 30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* get HotpCounter attribute
|
2020-11-12 00:09:33 +01:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getHotpCounterAttribute()
|
|
|
|
{
|
2020-11-22 11:00:55 +01:00
|
|
|
return isset($this->otp) && $this->otpType === 'hotp' ? $this->otp->getCounter() : null; // Default is 0
|
2020-11-12 00:09:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-18 01:13:00 +01:00
|
|
|
* set HotpCounter attribute
|
2020-11-12 00:09:33 +01:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function setHotpCounterAttribute($value)
|
|
|
|
{
|
|
|
|
$this->otp->setParameter( 'counter', $this->otp->getcounter() + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get Image parameter attribute
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getImageLinkAttribute()
|
|
|
|
{
|
2020-11-22 11:00:55 +01:00
|
|
|
if( isset($this->otp) ) {
|
|
|
|
return $this->otp->hasParameter('image') ? $this->otp->getParameter('image') : null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
2020-11-06 21:49:43 +01:00
|
|
|
}
|
|
|
|
|
2020-11-12 00:09:33 +01:00
|
|
|
}
|