Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return qualifier info in auth/check response #18

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}
}
Loading