Skip to content

Commit

Permalink
Fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
PlanetTheCloud committed Jul 13, 2023
1 parent abbafc8 commit 751bb42
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions sys-auth/api/signup.php
Expand Up @@ -64,6 +64,10 @@
}
}
if ($data['domain_type'] === 'custom') {
if (!config('system.features.signup.use_own_domain', false)) {
throw new ValidationFailedException(__('Signups using custom domains are currently disabled. Please use a free subdomain and try again.'), 'custom_domain');
}

$data['custom_domain'] = strtolower($data['custom_domain']);
if (!preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $data['custom_domain'])) {
throw new ValidationFailedException(__('The custom domain you provided is invalid. Please enter a valid custom domain and try again.'), 'custom_domain');
Expand Down
2 changes: 1 addition & 1 deletion sys-auth/app/config_parser.php
Expand Up @@ -19,7 +19,7 @@

# Handle System Config
$system = require SYSTEM . '/config/system.php';
$required = ['development_mode', 'maintenance_mode', 'maintenance_key', 'lockdown_mode', 'language', 'use_https', 'cpanel_url', 'domain_selection'];
$required = ['installation_url', 'development_mode', 'maintenance_mode', 'maintenance_key', 'lockdown_mode', 'language', 'use_https', 'cpanel_url', 'domain_selection', 'blacklisted_tld', 'default_plan', 'features'];
foreach ($required as $key) {
if (!isset($system[$key])) {
throw new InvalidConfigException("Missing '{$key}' field in 'system' config.");
Expand Down
3 changes: 3 additions & 0 deletions sys-auth/config/system.php
Expand Up @@ -31,6 +31,9 @@
'login' => [
'language_selector' => true,
'remember_me' => true,
],
'signup' => [
'use_own_domain' => false,
]
],
];
17 changes: 12 additions & 5 deletions sys-auth/pages/signup.php
@@ -1,3 +1,8 @@
<?php
// Optimizations for the form state in case the use own domain feature is disabled.
// Automatically selects the free subdomain option and keeps the element hidden.
$useOwnDomainBool = (config('system.features.signup.use_own_domain', false));
?>
<div class="body">
<div id="a_response" class="alert alert-danger mb-3 hidden">{{MESSAGE}}</div>
<div class="msg"><?= __('Sign up for a free account') ?></div>
Expand Down Expand Up @@ -41,15 +46,17 @@
</div>
<small class="col-pink hidden" id="warn_password_confirm">{{WARNING}}</small>
</div>
<div class="form-group" style="margin-bottom: 10px;">

<div class="form-group <?= (!$useOwnDomainBool) ? 'hidden' : '' ?>" style="margin-bottom: 10px;">
<i class="material-icons" style="position: absolute;z-index:10;margin-top:14px;margin-left:425px;" data-toggle="tooltip" data-placement="right" data-html="true" data-template="<div class='tooltip' role='tooltip'><div class='arrow'></div><div class='tooltip-inner' style='max-width: 250px;max-height:300px;'></div></div>" title="<?= __('If you already have a domain that you want to use with us, please select \'I have my own domain\'.<br><br>If you don\'t have a domain right now, you can choose \'I want to use a free subdomain\'.<br><br>Don\'t worry, you can always add more domains (including your own domain) later on from the Control Panel.') ?>">help</i>
<input type="radio" name="domain_type" value="custom" class="with-gap radio-col-<?= config('branding.accent_color'); ?>" id="i_domain_type_own">
<label for="i_domain_type_own"><?= __('I have my own domain') ?></label>
<br>
<input type="radio" name="domain_type" value="subdomain" class="with-gap radio-col-<?= config('branding.accent_color'); ?>" id="i_domain_type_sub">
<input type="radio" name="domain_type" value="subdomain" class="with-gap radio-col-<?= config('branding.accent_color'); ?>" id="i_domain_type_sub" <?= (!$useOwnDomainBool) ? 'checked="checked"' : '' ?>>
<label class="p-l-20" for="i_domain_type_sub"><?= __('I want to use a free subdomain') ?></label>
</div>
<small class="col-pink hidden" id="warn_domain_type">{{WARNING}}</small>

<div id="s_custom_domain" class="hidden">
<div class="infobox">
<?= __('To use your domain with us, point it to these nameservers:') ?><br>
Expand All @@ -67,7 +74,8 @@
<small class="col-pink hidden" id="warn_custom_domain">{{WARNING}}</small>
</div>
</div>
<div id="s_subdomain" class="hidden">

<div id="s_subdomain" class="<?= ($useOwnDomainBool) ? 'hidden' : '' ?>">
<div class="infobox" id="infobox_subdomain">
<?= __('Choose a subdomain and extension') ?>
</div>
Expand All @@ -94,7 +102,7 @@
</div>
</div>
</div>
<div id="s_others" class="hidden">
<div id="s_others" class="<?= ($useOwnDomainBool) ? 'hidden' : '' ?>">
<div class="form-group form-float">
<div style="margin-bottom: 20px;">
<img width="50%" src="https://ifastnet.com/image.php?id=<?= Page::param('captcha_id') ?>">
Expand All @@ -114,5 +122,4 @@
<a href="/auth/login"><?= __('Sign in to your account(s)') ?></a>
</div>
</form>
<script src="assets/signup.js"></script>
</div>

0 comments on commit 751bb42

Please sign in to comment.