mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 15:54:03 +00:00
User impersonation
This commit is contained in:
parent
52476d6298
commit
10a5b80d44
9 changed files with 432 additions and 2 deletions
41
src/Database/Models/ImpersonationToken.php
Normal file
41
src/Database/Models/ImpersonationToken.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Database\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Stancl\Tenancy\Database\Concerns\CentralConnection;
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
* @param string $tenant_id
|
||||
* @param string $user_id
|
||||
* @param string $auth_guard
|
||||
* @param string $redirect_url
|
||||
* @param Carbon $created_at
|
||||
*/
|
||||
class ImpersonationToken extends Model
|
||||
{
|
||||
use CentralConnection;
|
||||
|
||||
protected $guarded = [];
|
||||
public $timestamps = false;
|
||||
protected $primaryKey = 'token';
|
||||
public $incrementing = false;
|
||||
protected $table = 'tenant_user_impersonation_tokens';
|
||||
protected $dates = [
|
||||
'created_at',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$model->created_at = $model->created_at ?? $model->freshTimestamp();
|
||||
$model->token = $model->token ?? Str::random(128);
|
||||
$model->auth_guard = $model->auth_guard ?? config('auth.defaults.guard');
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue