Skip to content

Commit

Permalink
Merge pull request #298 from canyongbs/bugfix/AIDAPP-332
Browse files Browse the repository at this point in the history
[AIDAPP-332]: Unable to thumb up or thumb down an article
  • Loading branch information
Orrison authored Oct 24, 2024
2 parents cd4c2a6 + ab97c71 commit a01562b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ FILESYSTEM_DISK=s3
FILAMENT_FILESYSTEM_DISK=s3
QUEUE_CONNECTION=redis
AUDIT_QUEUE_CONNECTION=redis
SESSION_DRIVER=file
SESSION_DRIVER=redis
SESSION_LIFETIME=120
SESSION_CONNECTION=tenant
SESSION_CONNECTION=session
SESSION_DOMAIN=.${LANDLORD_APP_HOST}

REDIS_HOST=aidingapp-redis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ public function __invoke(StoreKnowledgeBaseArticleVoteRequest $request): JsonRes
{
$articleVote = [];
/**
* @param PortalGuest|Contact $voter
* @param PortalGuest|Contact|null $voter
*/
$voter = session()->has('guest_id') ? PortalGuest::find(session('guest_id')) : auth('contact')->user();
$voter = auth('contact')->user() ?? PortalGuest::find(session('guest_id'));

if (is_null($voter)) {
$voter = PortalGuest::create();
session()->put('guest_id', $voter->getKey());
}

if (! is_null($request->article_vote)) {
$articleVote = $voter->knowledgeBaseArticleVotes()->where('article_id', $request->article_id)->first();
Expand Down
1 change: 1 addition & 0 deletions app/Multitenancy/Tasks/SwitchSessionDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected function setSessionConfig(string $driver, string $connection, string $
'session.driver' => $driver,
'session.connection' => $connection,
'session.domain' => $domain,
'sanctum.stateful' => [$domain],
]);

app()->forgetInstance('session');
Expand Down

0 comments on commit a01562b

Please sign in to comment.