implement role assignment on sso user signups and log ip for sso logins
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { fetchUsers } from "@/api/accounts";
|
import { fetchUsers, fetchRoles } from "@/api/accounts";
|
||||||
import { formatUserOptions } from "@/utils/format";
|
import { formatUserOptions } from "@/utils/format";
|
||||||
|
|
||||||
export function useUserDropdown(onMount = false) {
|
export function useUserDropdown(onMount = false) {
|
||||||
@@ -44,3 +44,27 @@ export function useUserDropdown(onMount = false) {
|
|||||||
getDynamicUserOptions,
|
getDynamicUserOptions,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRoleDropdown(opts = {}) {
|
||||||
|
const roleOptions = ref([]);
|
||||||
|
async function getRoleOptions() {
|
||||||
|
const roles = await fetchRoles();
|
||||||
|
console.log(roles);
|
||||||
|
roleOptions.value = roles.map((role) => ({
|
||||||
|
value: role.id,
|
||||||
|
label: role.name,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.onMount) {
|
||||||
|
onMounted(getRoleOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
//data
|
||||||
|
roleOptions,
|
||||||
|
|
||||||
|
//methods
|
||||||
|
getRoleOptions,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@@ -36,7 +36,7 @@ function postForm(url: string, data: FormData) {
|
|||||||
|
|
||||||
// sso providers
|
// sso providers
|
||||||
|
|
||||||
export async function fetchSSOProviders(): Promise<SSOProvider> {
|
export async function fetchSSOProviders(): Promise<SSOProvider[]> {
|
||||||
const { data } = await axios.get(`${baseUrl}/ssoproviders/`);
|
const { data } = await axios.get(`${baseUrl}/ssoproviders/`);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,6 @@ export async function fetchSSOSettings(): Promise<SSOSettings> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function updateSSOSettings(settings: SSOSettings) {
|
export async function updateSSOSettings(settings: SSOSettings) {
|
||||||
console.log(settings);
|
|
||||||
const { data } = await axios.post(
|
const { data } = await axios.post(
|
||||||
`${baseUrl}/ssoproviders/settings/`,
|
`${baseUrl}/ssoproviders/settings/`,
|
||||||
settings,
|
settings,
|
||||||
|
@@ -60,6 +60,19 @@ For details, see: https://license.tacticalrmm.com/ee
|
|||||||
/>
|
/>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-section>
|
||||||
|
<tactical-dropdown
|
||||||
|
label="Default Role"
|
||||||
|
:options="roleOptions"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
clearable
|
||||||
|
mapOptions
|
||||||
|
filled
|
||||||
|
v-model="localProvider.role"
|
||||||
|
/>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
<q-card-actions align="right">
|
<q-card-actions align="right">
|
||||||
<q-btn flat label="Cancel" v-close-popup />
|
<q-btn flat label="Cancel" v-close-popup />
|
||||||
<q-btn
|
<q-btn
|
||||||
@@ -80,7 +93,13 @@ import { ref, reactive } from "vue";
|
|||||||
import { useDialogPluginComponent, extend } from "quasar";
|
import { useDialogPluginComponent, extend } from "quasar";
|
||||||
import { editSSOProvider, addSSOProvider } from "@/ee/sso/api/sso";
|
import { editSSOProvider, addSSOProvider } from "@/ee/sso/api/sso";
|
||||||
import { notifySuccess } from "@/utils/notify";
|
import { notifySuccess } from "@/utils/notify";
|
||||||
import { SSOProvider } from "@/types/accounts";
|
import { useRoleDropdown } from "@/composables/accounts";
|
||||||
|
|
||||||
|
// components
|
||||||
|
import TacticalDropdown from "@/components/ui/TacticalDropdown.vue";
|
||||||
|
|
||||||
|
// types
|
||||||
|
import type { SSOProvider } from "@/ee/sso/types/sso";
|
||||||
|
|
||||||
// define emits
|
// define emits
|
||||||
defineEmits([...useDialogPluginComponent.emits]);
|
defineEmits([...useDialogPluginComponent.emits]);
|
||||||
@@ -92,6 +111,8 @@ const { dialogRef, onDialogHide, onDialogOK } = useDialogPluginComponent();
|
|||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const { roleOptions } = useRoleDropdown({ onMount: true });
|
||||||
|
|
||||||
const localProvider: SSOProvider = props.provider
|
const localProvider: SSOProvider = props.provider
|
||||||
? reactive(extend({}, props.provider))
|
? reactive(extend({}, props.provider))
|
||||||
: reactive({
|
: reactive({
|
||||||
@@ -100,6 +121,7 @@ const localProvider: SSOProvider = props.provider
|
|||||||
client_id: "",
|
client_id: "",
|
||||||
secret: "",
|
secret: "",
|
||||||
server_url: "",
|
server_url: "",
|
||||||
|
role: null,
|
||||||
} as SSOProvider);
|
} as SSOProvider);
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
|
@@ -47,6 +47,7 @@ For details, see: https://license.tacticalrmm.com/ee
|
|||||||
"
|
"
|
||||||
no-caps
|
no-caps
|
||||||
color="primary"
|
color="primary"
|
||||||
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<!-- body slots -->
|
<!-- body slots -->
|
||||||
|
@@ -12,6 +12,7 @@ export interface SSOProvider {
|
|||||||
client_id: string;
|
client_id: string;
|
||||||
secret: string;
|
secret: string;
|
||||||
server_url: string;
|
server_url: string;
|
||||||
|
role: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SSOAccount {
|
export interface SSOAccount {
|
||||||
|
Reference in New Issue
Block a user