diff --git a/VERSION.txt b/VERSION.txt index ea2a8077c7..2eb4062f45 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.67 \ No newline at end of file +5.3.68 \ No newline at end of file diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index e608c4d74d..7e0993d30d 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -33,6 +33,7 @@ use App\Transformers\CompanyUserTransformer; use App\Utils\Ninja; use App\Utils\Traits\UserSessionAttributes; use App\Utils\Traits\User\LoginCache; +use App\Utils\TruthSource; use Google_Client; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; @@ -250,15 +251,6 @@ class LoginController extends BaseController ->increment() ->queue(); - // SystemLogger::dispatch( - // json_encode(['ip' => request()->getClientIp()]), - // SystemLog::CATEGORY_SECURITY, - // SystemLog::EVENT_USER, - // SystemLog::TYPE_LOGIN_FAILURE, - // null, - // Company::first(), - // ); - $this->incrementLoginAttempts($request); return response() @@ -310,7 +302,12 @@ class LoginController extends BaseController */ public function refresh(Request $request) { - $company_token = CompanyToken::where('token', $request->header('X-API-TOKEN'))->first(); + $truth = app()->make(TruthSource::class); + + if($truth->getCompanyToken()) + $company_token = $truth->getCompanyToken(); + else + $company_token = CompanyToken::where('token', $request->header('X-API-TOKEN'))->first(); $cu = CompanyUser::query() ->where('user_id', $company_token->user_id); diff --git a/app/Models/User.php b/app/Models/User.php index 5e0277895a..9fd2be78bc 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -247,14 +247,11 @@ class User extends Authenticatable implements MustVerifyEmail } return $this->token()->cu; - // return $this->company_user(); + } public function company_user() { - // if (! $this->id && auth()->user()) { - // $this->id = auth()->user()->id; - // } // return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'user_id', 'id', 'user_id') // ->withTrashed(); diff --git a/app/Transformers/CompanyUserTransformer.php b/app/Transformers/CompanyUserTransformer.php index 1f63e2716b..88d90cfede 100644 --- a/app/Transformers/CompanyUserTransformer.php +++ b/app/Transformers/CompanyUserTransformer.php @@ -16,6 +16,7 @@ use App\Models\Company; use App\Models\CompanyToken; use App\Models\CompanyUser; use App\Models\User; +use App\Utils\TruthSource; class CompanyUserTransformer extends EntityTransformer { @@ -79,7 +80,12 @@ class CompanyUserTransformer extends EntityTransformer public function includeToken(CompanyUser $company_user) { - $token = $company_user->tokens->where('company_id', $company_user->company_id)->where('user_id', $company_user->user_id)->first(); + $truth = app()->make(TruthSource::class); + + if($truth->getCompanyToken()) + $token = $truth->getCompanyToken(); + else + $token = $company_user->tokens->where('company_id', $company_user->company_id)->where('user_id', $company_user->user_id)->first(); $transformer = new CompanyTokenTransformer($this->serializer); diff --git a/config/ninja.php b/config/ninja.php index 404f05f3d8..8ed165ce9c 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.3.67', - 'app_tag' => '5.3.67', + 'app_version' => '5.3.68', + 'app_tag' => '5.3.68', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),