Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function admin(?string $registered_user_group,
string $email_verification_hint,
string $username_policy_regex,
?bool $admin_approval_required,
?bool $login_button_hide,
?bool $email_is_optional,
?bool $email_is_login,
?bool $show_fullname,
Expand Down Expand Up @@ -104,6 +105,7 @@ public function admin(?string $registered_user_group,
}

$this->config->setAppValue($this->appName, 'admin_approval_required', $admin_approval_required ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'login_button_hide', $login_button_hide ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'email_is_optional', $email_is_optional ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'email_is_login', !$email_is_optional && $email_is_login ? 'yes' : 'no');
$this->config->setAppValue($this->appName, 'show_fullname', $show_fullname ? 'yes' : 'no');
Expand Down
16 changes: 12 additions & 4 deletions lib/RegistrationLoginOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,32 @@
namespace OCA\Registration;

use OCP\Authentication\IAlternativeLogin;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;

class RegistrationLoginOption implements IAlternativeLogin {

public function __construct(protected IURLGenerator $url, protected IL10N $l, protected \OC_Defaults $theming) {
public function __construct(protected IConfig $config, protected IURLGenerator $url, protected IL10N $l, protected \OC_Defaults $theming) {
$this->config = $config;
}

public function getLabel(): string {
return $this->l->t('Register');
if ($this->config->getAppValue('registration', 'login_button_hide', 'no') === 'no') {
return $this->l->t('Register');
}
}

public function getLink(): string {
return $this->url->linkToRoute('registration.register.showEmailForm');
if ($this->config->getAppValue('registration', 'login_button_hide', 'no') === 'no') {
return $this->url->linkToRoute('registration.register.showEmailForm');
}
}

public function getClass(): string {
return 'register-button';
if ($this->config->getAppValue('registration', 'login_button_hide', 'no') === 'no') {
return 'register-button';
}
}

public function load(): void {
Expand Down
5 changes: 5 additions & 0 deletions lib/Settings/RegistrationSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public function getForm(): TemplateResponse {
$this->config->getAppValue($this->appName, 'admin_approval_required', 'no') === 'yes'
);

$this->initialState->provideInitialState(
'login_button_hide',
$this->config->getAppValue($this->appName, 'login_button_hide', 'no') === 'yes'
);

$this->initialState->provideInitialState(
'allowed_domains',
$this->config->getAppValue($this->appName, 'allowed_domains')
Expand Down
12 changes: 12 additions & 0 deletions src/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@

<p><em>{{ t('registration', 'Enabling "administrator approval" will prevent registrations from mobile and desktop clients to complete as the credentials cannot be verified by the client until the user was enabled.') }}</em></p>

<NcCheckboxRadioSwitch :checked.sync="loginButtonHide"
type="switch"
:disabled="loading"
@update:checked="saveData">
{{ t('registration', 'Hide registration button on login page') }}
</NcCheckboxRadioSwitch>

<p><em>{{ t('registration', 'Enabling, "hide registration button" will ensure the registration button is not displayed on the login page. Instead new users will have to be provided with the registration link, eg. https://nextcloud.domain.tld/index.php/apps/registration/, in order to register.') }}</em></p>

<div>
<div class="margin-top">
<label for="registered_user_group">
Expand Down Expand Up @@ -203,6 +212,7 @@ export default {
saveNotification: null,

adminApproval: false,
loginButtonHide: false,
registeredUserGroup: '',
allowedDomains: '',
domainsIsBlocklist: false,
Expand Down Expand Up @@ -239,6 +249,7 @@ export default {

mounted() {
this.adminApproval = loadState('registration', 'admin_approval_required')
this.loginButtonHide = loadState('registration', 'login_button_hide')
this.registeredUserGroup = loadState('registration', 'registered_user_group')
this.allowedDomains = loadState('registration', 'allowed_domains')
this.domainsIsBlocklist = loadState('registration', 'domains_is_blocklist')
Expand Down Expand Up @@ -270,6 +281,7 @@ export default {
try {
const response = await axios.post(generateUrl('/apps/registration/settings'), {
admin_approval_required: this.adminApproval,
login_button_hide: this.loginButtonHide,
registered_user_group: this.registeredUserGroup?.id,
allowed_domains: this.allowedDomains,
domains_is_blocklist: this.domainsIsBlocklist,
Expand Down