mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add CompanyToken to Truth
This commit is contained in:
parent
e2cd1e5c71
commit
eb5e8bf60c
@ -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);
|
||||
|
||||
/*
|
||||
|
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user