Skip to content

Commit 1d8a347

Browse files
committed
Prevent the linking of fake ckeys to forum accounts
Until a better solution is figured out.
1 parent fa58e81 commit 1d8a347

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

app/Http/Controllers/User/LinkController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ public function add(Request $request)
118118

119119
$ckey = Helpers::sanitize_ckey($request->input("Byond_Username"));
120120

121-
#Check if a player with that ckey exists
122-
$player_count = ServerPlayer::where('ckey', $ckey)->count();
121+
$player = ServerPlayer::where('ckey', $ckey)->first();
123122

124-
if ($player_count != 1) {
123+
#Check if a player with that ckey exists
124+
if (is_null($player)) {
125125
return redirect()->route('user.link')->withErrors(array("Could not find player with the ckey" . $ckey . ". You need to join on the server before you can link your account."));
126126
}
127127

128+
if ($player->ckey_is_external) {
129+
return redirect()->route('user.link')->withErrors(array("Your ckey " . $ckey . " is an external ckey. Linking forum accounts to these keys is currently not supported."));
130+
}
131+
128132
//Only add a new linking request if there is no existing one (where the deleted_at date is not set)
129133
if (DB::connection('server')->table('player_linking')->where('forum_id', '=', $request->user()->user_id)->where('deleted_at', '=', NULL)->count() == 0) {
130134

app/Models/ServerPlayer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ServerPlayer extends Model
2828
public $timestamps = FALSE;
2929
protected $connection = 'server';
3030
protected $table = 'player';
31-
protected $fillable = ['ckey', 'ip', 'whitelist_status'];
31+
protected $fillable = ['ckey', 'ip', 'whitelist_status', 'ckey_is_external'];
3232
protected $primaryKey = 'id';
3333
protected $dates = ['firstseen', 'lastseen'];
3434

0 commit comments

Comments
 (0)