Skip to content

Commit

Permalink
disable certain UI elements if block_local_user_local is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sadnub committed Oct 29, 2024
1 parent 16b9bf1 commit 54207d1
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 26 deletions.
16 changes: 4 additions & 12 deletions src/components/AdminManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@

<script>
import mixins from "@/mixins/mixins";
import { computed, onMounted, ref } from "vue";
import { computed } from "vue";
import { useStore } from "vuex";
import { useQuasar } from "quasar";
import { fetchCoreSettings } from "@/api/core";
import { mapState as piniaMapState } from "pinia";
import { useAuthStore } from "@/stores/auth";
Expand All @@ -206,11 +205,12 @@ export default {
// setup vuex
const store = useStore();
const formatDate = computed(() => store.getters.formatDate);
const localLogonDisabled = computed(
() => store.state.block_local_user_logon,
);
const $q = useQuasar();
const localLogonDisabled = ref(false);
function showSSOAccounts(user) {
$q.dialog({
component: SSOAccountsTable,
Expand All @@ -220,12 +220,6 @@ export default {
});
}
async function getCoreSettings() {
const result = await fetchCoreSettings();
localLogonDisabled.value = result.block_local_user_logon;
}
async function showSessions(user) {
$q.dialog({
component: UserSessionsTable,
Expand All @@ -235,8 +229,6 @@ export default {
});
}
onMounted(getCoreSettings);
return {
localLogonDisabled,
formatDate,
Expand Down
10 changes: 9 additions & 1 deletion src/components/modals/coresettings/EditCoreSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@
v-show="
tab !== 'customfields' &&
tab !== 'keystore' &&
tab !== 'urlactions'
tab !== 'urlactions' &&
tab !== 'sso'
"
label="Save"
color="primary"
Expand Down Expand Up @@ -774,6 +775,13 @@ export default {
return this.$store.state.hosted;
},
},
watch: {
tab(newTab, oldTab) {
if (oldTab === "sso") {
this.getCoreSettings();
}
},
},
methods: {
openURL(url) {
openURL(url);
Expand Down
6 changes: 6 additions & 0 deletions src/ee/sso/api/sso.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright (c) 2023-present Amidaware Inc.
This file is subject to the EE License Agreement.
For details, see: https://license.tacticalrmm.com/ee
*/

import axios from "axios";
import { getCookie } from "@/ee/sso/utils/cookies";
import { getBaseUrl } from "@/boot/axios";
Expand Down
6 changes: 6 additions & 0 deletions src/ee/sso/components/SSOProvidersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ For details, see: https://license.tacticalrmm.com/ee
<script setup lang="ts">
// composition imports
import { ref, onMounted } from "vue";
import { useStore } from "vuex";
import { QTableColumn, useQuasar, copyToClipboard } from "quasar";
import { fetchSSOProviders, removeSSOProvider } from "@/ee/sso/api/sso";
import { notifySuccess } from "@/utils/notify";
Expand All @@ -141,6 +142,9 @@ import SSOSettings from "@/ee/sso/components/SSOSettings.vue";
// setup quasar
const $q = useQuasar();

// setup vuew store
const store = useStore();

const loading = ref(false);
const providers = ref([] as SSOProvider[]);

Expand Down Expand Up @@ -228,6 +232,8 @@ function getCallbackURL(provider: SSOProvider) {
function openSSOSettings() {
$q.dialog({
component: SSOSettings,
}).onOk((ssoSettings: SSOSettings) => {
store.commit("setBlockLocalUserLogon", ssoSettings.block_local_user_logon);
});
}

Expand Down
23 changes: 11 additions & 12 deletions src/ee/sso/components/SSOSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ const { dialogRef, onDialogHide, onDialogOK } = useDialogPluginComponent();
const ssoSettings = ref({} as SSOSettings);
const loading = ref(false);

// watcher to disable block local login if sso is disabled
watch(
() => ssoSettings.value.sso_enabled,
(newValue) => {
if (newValue) {
ssoSettings.value.block_local_user_logon = false;
}
},
);
async function getSSOSettings() {
loading.value = true;
try {
Expand All @@ -88,10 +79,9 @@ async function getSSOSettings() {
async function submit() {
loading.value = true;
try {
ssoSettings.value = await updateSSOSettings(ssoSettings.value);
await getSSOSettings();
await updateSSOSettings(ssoSettings.value);
notifySuccess("Settings updated successfully");
onDialogOK();
onDialogOK(ssoSettings.value);
} catch (e) {
console.error(e);
}
Expand All @@ -100,5 +90,14 @@ async function submit() {

onMounted(async () => {
await getSSOSettings();
// watcher to disable block local login if sso is disabled
watch(
() => ssoSettings.value.sso_enabled,
(newValue) => {
if (newValue) {
ssoSettings.value.block_local_user_logon = false;
}
},
);
});
</script>
5 changes: 4 additions & 1 deletion src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
<q-item-label>Preferences</q-item-label>
</q-item-section>
</q-item>
<q-item clickable>
<q-item clickable v-if="!block_local_user_logon">
<q-item-section>Account</q-item-section>
<q-item-section side>
<q-icon name="keyboard_arrow_right" />
Expand Down Expand Up @@ -259,6 +259,9 @@ const hosted = computed(() => store.state.hosted);
const tokenExpired = computed(() => store.state.tokenExpired);
const dash_warning_color = computed(() => store.state.dash_warning_color);
const dash_negative_color = computed(() => store.state.dash_negative_color);
const block_local_user_logon = computed(
() => store.state.block_local_user_logon,
);
const latestReleaseURL = computed(() => {
return latestTRMMVersion.value
Expand Down
9 changes: 9 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default function () {
},
server_scripts_enabled: true,
web_terminal_enabled: true,
sso_enabled: false,
block_local_user_logon: false,
};
},
getters: {
Expand Down Expand Up @@ -159,6 +161,12 @@ export default function () {
setWebTerminalEnabled(state, obj) {
state.web_terminal_enabled = obj;
},
setSSOEnabled(state, obj) {
state.sso_enabled = obj;
},
setBlockLocalUserLogon(state, obj) {
state.block_local_user_logon = obj;
},
},
actions: {
setClientTreeSplitter(context, val) {
Expand Down Expand Up @@ -245,6 +253,7 @@ export default function () {
commit("setRunCmdPlaceholders", data.run_cmd_placeholder_text);
commit("setServerScriptsEnabled", data.server_scripts_enabled);
commit("setWebTerminalEnabled", data.web_terminal_enabled);
commit("setBlockLocalUserLogon", data.block_local_user_logon);

if (data?.date_format !== "") commit("setDateFormat", data.date_format);
else commit("setDateFormat", data.default_date_format);
Expand Down

0 comments on commit 54207d1

Please sign in to comment.