From 67f4a9ac84827d71b89af5aa5171dcd339783c14 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Sat, 29 Aug 2020 20:37:20 +0200 Subject: [PATCH] Fix some minor things regarding link validation --- app/Services/LodestoneLinkingService.php | 6 +++--- .../2020_08_28_193017_create_user_links_table.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Services/LodestoneLinkingService.php b/app/Services/LodestoneLinkingService.php index 0388a0c..fea430a 100644 --- a/app/Services/LodestoneLinkingService.php +++ b/app/Services/LodestoneLinkingService.php @@ -27,7 +27,7 @@ class LodestoneLinkingService public function getLinkDiscord($lodestoneId, $discordUserId) { // Check already linked - if (UserLink::where('lodestoneId', $lodestoneId)->count() > 0) { + if (UserLink::where('lodestoneId', $lodestoneId)->where('discordUserId', $discordUserId)->count() > 0) { return [ 'linked' => true, 'linkCode' => null, @@ -62,7 +62,7 @@ class LodestoneLinkingService public function getLinkWebsite($lodestoneId, $hostname, $websiteUserId) { // Check already linked - if (UserLink::where('lodestoneId', $lodestoneId)->count() > 0) { + if (UserLink::where('lodestoneId', $lodestoneId)->where('websiteUserId', $websiteUserId)->count() > 0) { return [ 'linked' => true, 'linkCode' => null, @@ -79,7 +79,7 @@ class LodestoneLinkingService } else { if ($linkCode !== null) $linkCode->delete(); - $code = $this->codeGeneratorService->generateCode('discord'); + $code = $this->codeGeneratorService->generateCode('website'); $linkCode = LinkCode::create([ 'lodestoneId' => $lodestoneId, 'websiteHostname' => $hostname, diff --git a/database/migrations/2020_08_28_193017_create_user_links_table.php b/database/migrations/2020_08_28_193017_create_user_links_table.php index 9963743..9471943 100644 --- a/database/migrations/2020_08_28_193017_create_user_links_table.php +++ b/database/migrations/2020_08_28_193017_create_user_links_table.php @@ -17,7 +17,7 @@ class CreateUserLinksTable extends Migration $table->id(); $table->bigInteger('lodestoneId')->unsigned()->unique(); $table->bigInteger('discordUserId')->unsigned()->nullable()->unique(); - $table->bigInteger('websiteHostname')->unsigned()->nullable(); + $table->string('websiteHostname', 255)->nullable(); $table->bigInteger('websiteUserId')->unsigned()->nullable(); $table->timestamps(); });