Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use App\Entitlement; | use App\Entitlement; | ||||
use App\UserAlias; | use App\UserAlias; | ||||
use App\Sku; | use App\Sku; | ||||
use App\Traits\UserConfigTrait; | |||||
use App\Traits\UserAliasesTrait; | use App\Traits\UserAliasesTrait; | ||||
use App\Traits\SettingsTrait; | use App\Traits\SettingsTrait; | ||||
use App\Wallet; | use App\Wallet; | ||||
use Illuminate\Database\Eloquent\SoftDeletes; | use Illuminate\Database\Eloquent\SoftDeletes; | ||||
use Illuminate\Foundation\Auth\User as Authenticatable; | use Illuminate\Foundation\Auth\User as Authenticatable; | ||||
use Iatstuti\Database\Support\NullableFields; | use Iatstuti\Database\Support\NullableFields; | ||||
use Tymon\JWTAuth\Contracts\JWTSubject; | use Tymon\JWTAuth\Contracts\JWTSubject; | ||||
/** | /** | ||||
* The eloquent definition of a User. | * The eloquent definition of a User. | ||||
* | * | ||||
* @property string $email | * @property string $email | ||||
* @property int $id | * @property int $id | ||||
* @property string $password | * @property string $password | ||||
* @property int $status | * @property int $status | ||||
* @property int $tenant_id | * @property int $tenant_id | ||||
*/ | */ | ||||
class User extends Authenticatable implements JWTSubject | class User extends Authenticatable implements JWTSubject | ||||
{ | { | ||||
use NullableFields; | use NullableFields; | ||||
use UserConfigTrait; | |||||
use UserAliasesTrait; | use UserAliasesTrait; | ||||
use SettingsTrait; | use SettingsTrait; | ||||
use SoftDeletes; | use SoftDeletes; | ||||
// a new user, default on creation | // a new user, default on creation | ||||
public const STATUS_NEW = 1 << 0; | public const STATUS_NEW = 1 << 0; | ||||
// it's been activated | // it's been activated | ||||
public const STATUS_ACTIVE = 1 << 1; | public const STATUS_ACTIVE = 1 << 1; | ||||
▲ Show 20 Lines • Show All 546 Lines • ▼ Show 20 Lines | public function removeSku(Sku $sku, int $count = 1): User | ||||
$entitlements_count--; | $entitlements_count--; | ||||
$count--; | $count--; | ||||
} | } | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function senderPolicyFrameworkWhitelist($clientName) | |||||
{ | |||||
$setting = $this->getSetting('spf_whitelist'); | |||||
if (!$setting) { | |||||
return false; | |||||
} | |||||
$whitelist = json_decode($setting); | |||||
$matchFound = false; | |||||
foreach ($whitelist as $entry) { | |||||
if (substr($entry, 0, 1) == '/') { | |||||
$match = preg_match($entry, $clientName); | |||||
if ($match) { | |||||
$matchFound = true; | |||||
} | |||||
continue; | |||||
} | |||||
if (substr($entry, 0, 1) == '.') { | |||||
if (substr($clientName, (-1 * strlen($entry))) == $entry) { | |||||
$matchFound = true; | |||||
} | |||||
continue; | |||||
} | |||||
if ($entry == $clientName) { | |||||
$matchFound = true; | |||||
continue; | |||||
} | |||||
} | |||||
return $matchFound; | |||||
} | |||||
/** | /** | ||||
* Any (additional) properties of this user. | * Any (additional) properties of this user. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | * @return \Illuminate\Database\Eloquent\Relations\HasMany | ||||
*/ | */ | ||||
public function settings() | public function settings() | ||||
{ | { | ||||
return $this->hasMany('App\UserSetting', 'user_id'); | return $this->hasMany('App\UserSetting', 'user_id'); | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |