mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fixes for company user resolution
This commit is contained in:
parent
696a5ac83b
commit
b4f2bba053
@ -31,7 +31,7 @@ class TokenAuth
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with(['user', 'company', 'cu'])->where('token', $request->header('X-API-TOKEN'))->first())) {
|
if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with(['user', 'company'])->where('token', $request->header('X-API-TOKEN'))->first())) {
|
||||||
|
|
||||||
$user = $company_token->user;
|
$user = $company_token->user;
|
||||||
|
|
||||||
|
@ -59,6 +59,13 @@ class CompanyToken extends BaseModel
|
|||||||
|
|
||||||
public function cu()
|
public function cu()
|
||||||
{
|
{
|
||||||
return $this->hasOneThrough(CompanyUser::class, Company::class, 'id', 'company_id', 'company_id', 'id');
|
return $this->hasOne(CompanyUser::class, 'user_id', 'user_id')
|
||||||
|
->where('company_id', $this->company_id)
|
||||||
|
->where('user_id', $this->user_id);
|
||||||
|
|
||||||
|
// return $this->company_user;
|
||||||
|
// return $this->belongsTo(CompanyUser::class)->where('user_id', $this->user_id);
|
||||||
|
|
||||||
|
// return $this->hasOneThrough(CompanyUser::class, Company::class, 'id', 'company_id', 'company_id', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user