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 { fetchUsers } from "@/api/accounts";
|
||||
import { fetchUsers, fetchRoles } from "@/api/accounts";
|
||||
import { formatUserOptions } from "@/utils/format";
|
||||
|
||||
export function useUserDropdown(onMount = false) {
|
||||
@@ -44,3 +44,27 @@ export function useUserDropdown(onMount = false) {
|
||||
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
|
||||
|
||||
export async function fetchSSOProviders(): Promise<SSOProvider> {
|
||||
export async function fetchSSOProviders(): Promise<SSOProvider[]> {
|
||||
const { data } = await axios.get(`${baseUrl}/ssoproviders/`);
|
||||
return data;
|
||||
}
|
||||
@@ -66,7 +66,6 @@ export async function fetchSSOSettings(): Promise<SSOSettings> {
|
||||
}
|
||||
|
||||
export async function updateSSOSettings(settings: SSOSettings) {
|
||||
console.log(settings);
|
||||
const { data } = await axios.post(
|
||||
`${baseUrl}/ssoproviders/settings/`,
|
||||
settings,
|
||||
|
@@ -60,6 +60,19 @@ For details, see: https://license.tacticalrmm.com/ee
|
||||
/>
|
||||
</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-btn flat label="Cancel" v-close-popup />
|
||||
<q-btn
|
||||
@@ -80,7 +93,13 @@ import { ref, reactive } from "vue";
|
||||
import { useDialogPluginComponent, extend } from "quasar";
|
||||
import { editSSOProvider, addSSOProvider } from "@/ee/sso/api/sso";
|
||||
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
|
||||
defineEmits([...useDialogPluginComponent.emits]);
|
||||
@@ -92,6 +111,8 @@ const { dialogRef, onDialogHide, onDialogOK } = useDialogPluginComponent();
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const { roleOptions } = useRoleDropdown({ onMount: true });
|
||||
|
||||
const localProvider: SSOProvider = props.provider
|
||||
? reactive(extend({}, props.provider))
|
||||
: reactive({
|
||||
@@ -100,6 +121,7 @@ const localProvider: SSOProvider = props.provider
|
||||
client_id: "",
|
||||
secret: "",
|
||||
server_url: "",
|
||||
role: null,
|
||||
} as SSOProvider);
|
||||
|
||||
async function submit() {
|
||||
|
@@ -47,6 +47,7 @@ For details, see: https://license.tacticalrmm.com/ee
|
||||
"
|
||||
no-caps
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</template>
|
||||
<!-- body slots -->
|
||||
|
@@ -12,6 +12,7 @@ export interface SSOProvider {
|
||||
client_id: string;
|
||||
secret: string;
|
||||
server_url: string;
|
||||
role: number | null;
|
||||
}
|
||||
|
||||
export interface SSOAccount {
|
||||
|
Reference in New Issue
Block a user