Skip to content

Commit

Permalink
staging Return qualifier info in auth/check response
Browse files Browse the repository at this point in the history
  • Loading branch information
latheesan-k committed Dec 8, 2024
1 parent e1bbeeb commit 7834f34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion application/app/Http/Controllers/API/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public function check(string $publicApiKey, Request $request): JsonResponse
// Load session and account info
$projectAccountSession = ProjectAccountSession::query()
->where('reference', $request->get('reference'))
->with(['account', 'project'])
->with(['account', 'project', 'stats'])
->whereHas('project', static function ($query) use ($publicApiKey) {
$query->where('public_api_key', $publicApiKey);
})
Expand Down Expand Up @@ -425,6 +425,7 @@ public function check(string $publicApiKey, Request $request): JsonResponse
'auth_country_code' => $projectAccountSession->auth_country_code,
'authenticated_at' => $projectAccountSession->authenticated_at->toDateTimeString(),
] : null,
'qualifier' => $isAuthenticated && isset($projectAccountSession->stats['qualifier']) ? $projectAccountSession->stats['qualifier'] : null,
];

});
Expand Down
6 changes: 6 additions & 0 deletions application/app/Models/ProjectAccountSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasOneThrough;

class ProjectAccountSession extends Model
Expand All @@ -29,4 +30,9 @@ public function project(): HasOneThrough
{
return $this->hasOneThrough(Project::class, ProjectAccount::class, 'id', 'id', 'project_account_id', 'project_id');
}

public function stats(): HasOne
{
return $this->hasOne(ProjectAccountStats::class, 'project_account_id', 'project_account_id');
}
}

0 comments on commit 7834f34

Please sign in to comment.