Fix some minor things regarding link validation

This commit is contained in:
Daniel_I_Am 2020-08-29 20:37:20 +02:00
parent 8cd67a026d
commit 67f4a9ac84
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84
2 changed files with 4 additions and 4 deletions

View File

@ -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,

View File

@ -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();
});