Add CompanyToken to Truth

This commit is contained in:
David Bomba 2022-03-13 20:24:58 +11:00
parent e2cd1e5c71
commit eb5e8bf60c
3 changed files with 21 additions and 0 deletions

View File

@ -58,6 +58,7 @@ class TokenAuth
$truth->setCompanyUser($company_token->cu);
$truth->setUser($company_token->user);
$truth->setCompany($company_token->company);
$truth->setCompanyToken($company_token);
/*
|

View File

@ -145,6 +145,12 @@ class User extends Authenticatable implements MustVerifyEmail
public function token()
{
$truth = app()->make(TruthSource::class);
if($truth->getCompanyToken()){
return $truth->getCompanyToken();
}
if (request()->header('X-API-TOKEN')) {
return CompanyToken::with(['cu'])->where('token', request()->header('X-API-TOKEN'))->first();
}

View File

@ -21,6 +21,7 @@ class TruthSource
public $company_user;
public $company_token;
public function setCompanyUser($company_user)
{
@ -39,6 +40,13 @@ class TruthSource
return $this;
}
public function setCompanyToken($company_token)
{
$this->company_token = $company_token;
return $this;
}
public function getCompany()
{
return $this->company;
@ -53,4 +61,10 @@ class TruthSource
{
return $this->user;
}
public function getCompanyToken()
{
return $this->company_token;
}
}