mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 12:24:35 -04:00
TruthSource in Login
This commit is contained in:
parent
ddbe971878
commit
00e070bd1b
@ -217,6 +217,12 @@ class LoginController extends BaseController
|
|||||||
$cu = CompanyUser::query()
|
$cu = CompanyUser::query()
|
||||||
->where('user_id', auth()->user()->id);
|
->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())
|
if(!$cu->exists())
|
||||||
return response()->json(['message' => 'User not linked to any companies'], 403);
|
return response()->json(['message' => 'User not linked to any companies'], 403);
|
||||||
|
|
||||||
|
@ -32,6 +32,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', 'cu'])->where('token', $request->header('X-API-TOKEN'))->first())) {
|
||||||
|
|
||||||
$user = $company_token->user;
|
$user = $company_token->user;
|
||||||
|
|
||||||
$error = [
|
$error = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user