2025-01-19 19:12:00 +01:00
|
|
|
<script setup>
|
|
|
|
|
|
2025-05-13 18:11:10 +02:00
|
|
|
import { ref, onMounted, inject } from 'vue';
|
2025-03-03 11:34:45 +01:00
|
|
|
import { Switch } from 'pankow';
|
2025-01-21 17:08:09 +01:00
|
|
|
import Section from '../components/Section.vue';
|
2025-03-26 16:04:58 +01:00
|
|
|
import SettingsItem from '../components/SettingsItem.vue';
|
2025-01-21 17:08:09 +01:00
|
|
|
import ExternalLdap from '../components/ExternalLdap.vue';
|
2025-01-19 19:12:00 +01:00
|
|
|
import UserDirectoryModel from '../models/UserDirectoryModel.js';
|
|
|
|
|
|
2025-05-13 18:11:10 +02:00
|
|
|
const features = inject('features');
|
|
|
|
|
|
2025-01-31 21:02:48 +01:00
|
|
|
const userDirectoryModel = UserDirectoryModel.create();
|
2025-01-19 19:12:00 +01:00
|
|
|
|
2025-05-13 18:11:10 +02:00
|
|
|
const busy = ref(false);
|
2025-01-19 19:12:00 +01:00
|
|
|
const editableUserProfiles = ref(false);
|
|
|
|
|
const mandatory2FA = ref(false);
|
|
|
|
|
|
2025-05-13 18:11:10 +02:00
|
|
|
async function onToggleMandatory2FA(value) {
|
|
|
|
|
busy.value = true;
|
2025-01-19 19:12:00 +01:00
|
|
|
|
2025-05-13 18:11:10 +02:00
|
|
|
const [error] = await userDirectoryModel.setGlobalProfileConfig({ mandatory2FA: value, lockUserProfiles: !editableUserProfiles.value });
|
|
|
|
|
if (error) {
|
|
|
|
|
mandatory2FA.value = !value;
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
busy.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function onToggleEditableUserProfiles(value) {
|
|
|
|
|
busy.value = true;
|
|
|
|
|
|
|
|
|
|
const [error] = await userDirectoryModel.setGlobalProfileConfig({ mandatory2FA: mandatory2FA.value, lockUserProfiles: !value });
|
|
|
|
|
if (error) {
|
|
|
|
|
editableUserProfiles.value = !value;
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
busy.value = false;
|
|
|
|
|
}
|
2025-01-19 19:12:00 +01:00
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
const [error, result] = await userDirectoryModel.getGlobalProfileConfig();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
editableUserProfiles.value = !result.lockUserProfiles;
|
|
|
|
|
mandatory2FA.value = result.mandatory2FA;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="content">
|
2025-05-22 15:16:04 +02:00
|
|
|
<Section :title="$t('users.title')" :padding="false" :title-badge="!features.profileConfig ? 'Upgrade' : ''">
|
2025-03-26 16:04:58 +01:00
|
|
|
<SettingsItem>
|
|
|
|
|
<div>{{ $t('users.settings.allowProfileEditCheckbox') }} <sup><a href="https://docs.cloudron.io/user-directory/#lock-profile" target="_blank"><i class="fa fa-question-circle"></i></a></sup></div>
|
2025-05-13 18:11:10 +02:00
|
|
|
<Switch v-model="editableUserProfiles" @change="onToggleEditableUserProfiles" :disabled="busy || !features.profileConfig"/>
|
2025-03-26 16:04:58 +01:00
|
|
|
</SettingsItem>
|
|
|
|
|
|
|
|
|
|
<SettingsItem>
|
|
|
|
|
<div>{{ $t('users.settings.require2FACheckbox') }}</div>
|
2025-05-13 18:11:10 +02:00
|
|
|
<Switch v-model="mandatory2FA" @change="onToggleMandatory2FA" :disabled="busy || !features.profileConfig"/>
|
2025-03-26 16:04:58 +01:00
|
|
|
</SettingsItem>
|
2025-01-19 19:12:00 +01:00
|
|
|
</Section>
|
|
|
|
|
|
|
|
|
|
<ExternalLdap />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|