TruthSource in Login

This commit is contained in:
David Bomba 2022-03-14 11:02:00 +11:00
parent ddbe971878
commit 00e070bd1b
2 changed files with 7 additions and 0 deletions

View File

@ -217,6 +217,12 @@ class LoginController extends BaseController
$cu = CompanyUser::query()
->where('user_id', auth()->user()->id);
$truth = app()->make(TruthSource::class);
$truth->setCompanyUser($cu->first());
$truth->setUser(auth()->user());
$truth->setCompany($user->account->default_company);
if(!$cu->exists())
return response()->json(['message' => 'User not linked to any companies'], 403);

View File

@ -32,6 +32,7 @@ class TokenAuth
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())) {
$user = $company_token->user;
$error = [