mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-09-09 11:45:18 -05:00
Added Check to game steam login to verify if the user needs to have a special role to play the game.
the role/s can be set in the .env with `ROLES_ALLOWED_TO_PLAY=`
This commit is contained in:
@@ -31,6 +31,13 @@ public function login(SteamLoginRequest $request)
|
||||
}
|
||||
|
||||
$foundUser = User::firstOrCreate(['steam_id' => $steamResponse->steamId], ['source' => 'GAME', 'steam_id' => $steamResponse->steamId]);
|
||||
|
||||
if(!$this->checkIfPlayAllowed($foundUser)) {
|
||||
$log->notice('User with SteamID "{id}" denied login. User has not sufficent roele', ['id' => $steamResponse->steamId]);
|
||||
return response('Unauthorized: Not Allowed', 401);
|
||||
}
|
||||
|
||||
|
||||
Auth::login($foundUser);
|
||||
|
||||
$this->fillSteamData($foundUser);
|
||||
@@ -64,4 +71,10 @@ protected function fillSteamData(User &$user): void
|
||||
$user->avatar_full = $player->avatarFull;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
protected function checkIfPlayAllowed(User &$user): bool {
|
||||
if(config('app.roles_allowed_to_play') === null)
|
||||
return true;
|
||||
return $user->hasAnyRole(config('app.roles_allowed_to_play'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user