Merge branch 'maint/misc-fixes' into 'main'
v1.1.0 See merge request future-gamers/rbrecruiter-gc!6
13
.env.example
@ -13,6 +13,19 @@ APP_AUTH_BANNER=""
|
||||
APP_SITEHOMEPAGE=""
|
||||
API_PREFIX="api"
|
||||
|
||||
|
||||
# FEATURE OVERRIDES
|
||||
# Feature overrides allow you to force-enable/disable features regardless of application settings and feature flags
|
||||
# Turning on the override will disable its feature
|
||||
|
||||
# Possible values:
|
||||
# KILLSWITCH: Disables the feature altogether
|
||||
# FORCE_ENABLE: Enables the feature
|
||||
# CONTROL: Lets the application settings and feature flags take effect (default)
|
||||
|
||||
# Require valid game license to sign up
|
||||
OVERRIDE_LICENSED_ACCOUNT=CONTROL
|
||||
|
||||
# Add legal document links here. You may also leave them empty.
|
||||
GUIDELINES_URL="#"
|
||||
PRIVACY_URL="#"
|
||||
|
10
app/Enums/OverridableFeatures.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum OverridableFeatures:string
|
||||
{
|
||||
|
||||
case REQUIRE_LICENSE = 'requireGameLicense';
|
||||
|
||||
}
|
23
app/Enums/Overrides.php
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum Overrides:int
|
||||
{
|
||||
|
||||
/**
|
||||
* Pass control to app settings
|
||||
*/
|
||||
case control = 0;
|
||||
|
||||
/**
|
||||
* Forcefully enable feature
|
||||
*/
|
||||
case forceEnable = 1;
|
||||
|
||||
/**
|
||||
* Forcefully disable feature
|
||||
*/
|
||||
case killSwitch = 2;
|
||||
|
||||
}
|
0
app/Exceptions/DiscordAccountRequiredException.php
Normal file → Executable file
0
app/Exceptions/IncompatibleAgeException.php
Normal file → Executable file
0
app/Exceptions/InvalidAgeException.php
Normal file → Executable file
@ -21,18 +21,20 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Enums\OverridableFeatures;
|
||||
use App\Enums\Overrides;
|
||||
use App\Exceptions\EmptyOptionsException;
|
||||
use App\Exceptions\OptionNotFoundException;
|
||||
use App\Options as Option;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LogicException;
|
||||
|
||||
|
||||
/**
|
||||
* The options class. A simple wrapper around the model. Could be a repository, but we're not using that design pattern just yet
|
||||
*/
|
||||
class Options
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an assortment of settings found in the mentioned category
|
||||
*
|
||||
@ -64,13 +66,46 @@ class Options
|
||||
Cache::put($option, $value->option_value);
|
||||
Cache::put($option.'_desc', 'Undefined description');
|
||||
|
||||
return $value->option_value;
|
||||
return $this->modifyResponse($option, $value->option_value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $this->modifyResponse($option, $value);
|
||||
}
|
||||
|
||||
// Null categories are settings without categories and will appear ungrouped
|
||||
public function isFeature(string $optionName): bool
|
||||
{
|
||||
if ($this->getCategory('app_features')->contains('option_name', $optionName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* CHeck if given option is locallu overriden
|
||||
*
|
||||
* @param string $option Option to check
|
||||
* @throws LogicException Thrown when feature is not locally overridable, e.g. not defined in the settings file
|
||||
* @return bool
|
||||
*/
|
||||
public function isOverriden(string $option): bool {
|
||||
|
||||
if (!array_key_exists($option, config('local-overrides.features'))) {
|
||||
throw new LogicException('Feature does not exist or is not locally overridable');
|
||||
}
|
||||
$feature = config("local-overrides.features.$option");
|
||||
|
||||
return ($feature == Overrides::forceEnable->value || $feature == Overrides::killSwitch->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines an option to store in the database.
|
||||
*
|
||||
* @param string $option Option name.
|
||||
* @param string $value Option value.
|
||||
* @param string $description Description for this, can be null
|
||||
* @param string|null $category Option category
|
||||
* @return void
|
||||
*/
|
||||
public function setOption(string $option, string $value, string $description, string $category = null)
|
||||
{
|
||||
Option::create([
|
||||
@ -84,6 +119,12 @@ class Options
|
||||
Cache::put($option.'_desc', $description, now()->addDay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets and deletes option
|
||||
*
|
||||
* @param string $option Option to pull
|
||||
* @return array
|
||||
*/
|
||||
public function pullOption($option): array
|
||||
{
|
||||
$oldOption = Option::where('option_name', $option)->first();
|
||||
@ -96,6 +137,14 @@ class Options
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an option
|
||||
*
|
||||
* @param $option
|
||||
* @param $newValue
|
||||
* @return void
|
||||
* @throws OptionNotFoundException
|
||||
*/
|
||||
public function changeOption($option, $newValue)
|
||||
{
|
||||
$dbOption = Option::where('option_name', $option);
|
||||
@ -123,6 +172,12 @@ class Options
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if option exists
|
||||
*
|
||||
* @param string $option
|
||||
* @return bool
|
||||
*/
|
||||
public function optionExists(string $option): bool
|
||||
{
|
||||
$dbOption = Option::where('option_name', $option)->first();
|
||||
@ -130,4 +185,52 @@ class Options
|
||||
|
||||
return ! is_null($dbOption) || ! is_null($locallyCachedOption);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the actual status for the override in question
|
||||
*
|
||||
* @param string $option
|
||||
* @return bool|Overrides
|
||||
*/
|
||||
public function getOverride(string $option): bool|string {
|
||||
return config("local-overrides.features.$option");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifies the outgoing option value according to its override value
|
||||
*
|
||||
* @param string $option
|
||||
* @param int|string $value Setting value
|
||||
* @return int|string Modified setting value accordidng to business rules
|
||||
*/
|
||||
private function modifyResponse(string $option, int|string $value): int|string
|
||||
{
|
||||
// TODO: This method should handle bools (feature on/off), we need to move this to getOption, but only after its been refactored. (this is a quick fix)
|
||||
if (!$this->isFeature($option)) {
|
||||
return $value;
|
||||
}
|
||||
$modifiedValue = $value;
|
||||
|
||||
try {
|
||||
|
||||
if ($this->isOverriden($option) && $this->getOverride($option) == Overrides::forceEnable->value) {
|
||||
$modifiedValue = Overrides::forceEnable->value;
|
||||
}
|
||||
|
||||
if ($this->isOverriden($option) && $this->getOverride($option) == Overrides::killSwitch->value) {
|
||||
$modifiedValue = 0;
|
||||
}
|
||||
|
||||
} catch (LogicException $exception) {
|
||||
Log::debug('Illegal attempt to modify setting value: not overridable; not modifying', [
|
||||
'msg' => $exception->getMessage()
|
||||
]);
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $modifiedValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
0
app/Http/Requests/AddDobRequest.php
Normal file → Executable file
0
app/Http/Requests/Reset2FASecretRequest.php
Normal file → Executable file
0
app/Http/Requests/SetNewPasswordRequest.php
Normal file → Executable file
0
app/Notifications/TwoFactorResetNotification.php
Normal file → Executable file
0
app/Services/DiscordService.php
Normal file → Executable file
@ -47,7 +47,10 @@
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
|
1630
composer.lock
generated
Normal file → Executable file
0
config/enlightn.php
Normal file → Executable file
9
config/local-overrides.php
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'features' => [
|
||||
'requireGameLicense' => env('OVERRIDE_LICENSED_ACCOUNT', 0)
|
||||
]
|
||||
|
||||
];
|
0
database/migrations/2014_04_02_193005_create_translations_table.php
Normal file → Executable file
0
database/migrations/2022_10_15_023108_update_vacancy_integration_nullable.php
Normal file → Executable file
0
database/migrations/2022_10_22_014237_add_discord_requirement_to_vacancies.php
Normal file → Executable file
0
database/migrations/2022_10_23_174610_add_required_age_to_vacancies.php
Normal file → Executable file
@ -46,7 +46,9 @@ class DefaultOptionsSeeder extends Seeder
|
||||
Options::setOption('password_expiry', '0', 'Defines wether passwords must be reset after $value', 'app_security');
|
||||
Options::setOption('force2fa', false, 'Defines whether 2fa is forced upon users', 'app_security');
|
||||
Options::setOption('force2faRole', 'reviewer', 'Defines which role to force 2fa for', 'app_security');
|
||||
Options::setOption('requireGameLicense', true, 'Defines whether people need to validate their game license', 'app_security');
|
||||
|
||||
|
||||
Options::setOption('requireGameLicense', true, 'Defines whether people need to validate their game license', 'app_features');
|
||||
|
||||
Options::setOption('currentGame', 'MINECRAFT', 'Defines what game we\'re working with', 'app_integration');
|
||||
|
||||
|
0
public/img/brand/brand_fg.svg
Normal file → Executable file
Before Width: | Height: | Size: 301 KiB After Width: | Height: | Size: 301 KiB |
0
public/img/brand/favi.svg
Normal file → Executable file
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 334 KiB |
0
public/img/brand/logo-future-gamers-comFundo.jpg
Normal file → Executable file
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
0
public/img/brand/logo-future-gamers-simples.png
Normal file → Executable file
Before Width: | Height: | Size: 318 KiB After Width: | Height: | Size: 318 KiB |
0
public/img/small_logo_blurple_RGB.svg
Normal file → Executable file
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
0
public/slides/homepage.jpg
Normal file → Executable file
Before Width: | Height: | Size: 672 KiB After Width: | Height: | Size: 672 KiB |
0
public/vendor/adminlte/dist/js/.eslintrc.json
vendored
Normal file → Executable file
@ -52,7 +52,7 @@
|
||||
@if($demoActive)
|
||||
<div class="alert alert-warning">
|
||||
<p class="font-weight-bold"><i class="fas fa-exclamation-triangle"></i>{{ __('Warning') }}</p>
|
||||
<p>{{ __('Do not use real credentials here. The application is in demo mode. Additionally, the database is wiped every six hours.') }}</p>
|
||||
<p>{{ __('Do not use real credentials here. The application is in demo mode. Additionally, the database is wiped every day.') }}</p>
|
||||
|
||||
<p>{{ __("Also note: If a game license is required to sign up, you may find valid MC usernames at NameMC. No special validation is performed other than contacting Mojang's authentication servers to verify the username's existence, therefore, you can use any username for testing purposes.") }}</p>
|
||||
</div>
|
||||
|
@ -44,7 +44,7 @@
|
||||
</ul>
|
||||
<p>{{ __('To keep everyone safe, IP addresses are censored everywhere in the app, and they\'re also not collected during registration. The IP address lookup feature is also disabled.') }}</p>
|
||||
<p>{{ __('Only system administrators can disable demo mode - it cannot be disabled via app settings.') }}</p>
|
||||
<p class="font-weight-bold">{{ __('Note! The database is wiped every six hours during demo mode.') }}</p>
|
||||
<p class="font-weight-bold">{{ __('Note! The database is wiped every day during demo mode.') }}</p>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|