generated from corrad-software/corrad-af-2024
127 lines
5.2 KiB
Vue
127 lines
5.2 KiB
Vue
<script setup>
|
|
import { useDmsStore } from '~/stores/dms';
|
|
import { onMounted } from 'vue';
|
|
|
|
// Define page metadata
|
|
definePageMeta({
|
|
title: "Check User Role",
|
|
middleware: ["auth"],
|
|
requiresAuth: true,
|
|
breadcrumb: [
|
|
{
|
|
name: "DMS",
|
|
path: "/dms",
|
|
},
|
|
{
|
|
name: "Check Role",
|
|
path: "/dms/check-role",
|
|
},
|
|
],
|
|
});
|
|
|
|
// Get the DMS store
|
|
const dmsStore = useDmsStore();
|
|
|
|
// Get current user details
|
|
const currentUser = dmsStore.currentUser;
|
|
|
|
// Log user role to console on component mount
|
|
onMounted(() => {
|
|
console.log('---------------------------------------');
|
|
console.log('Current User Information:');
|
|
console.log('---------------------------------------');
|
|
console.log('Name:', currentUser.name);
|
|
console.log('Email:', currentUser.email);
|
|
console.log('Role:', currentUser.role);
|
|
console.log('Department:', currentUser.department);
|
|
console.log('User ID:', currentUser.id);
|
|
console.log('---------------------------------------');
|
|
|
|
// Check if user has admin permissions
|
|
const isAdmin = currentUser.role === 'admin';
|
|
console.log('Has Admin Privileges:', isAdmin ? 'YES' : 'NO');
|
|
|
|
// Get detailed permissions (async)
|
|
dmsStore.getRbacPermissions(currentUser.id).then(permissions => {
|
|
console.log('---------------------------------------');
|
|
console.log('Detailed Permissions:');
|
|
console.log('---------------------------------------');
|
|
console.log(JSON.stringify(permissions, null, 2));
|
|
console.log('---------------------------------------');
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="check-role-page">
|
|
<LayoutsBreadcrumb />
|
|
|
|
<rs-card class="h-full">
|
|
<template #body>
|
|
<div class="p-6">
|
|
<h1 class="text-2xl font-semibold mb-4">User Role Information</h1>
|
|
|
|
<div class="bg-blue-50 dark:bg-blue-900/10 rounded-lg p-5 mb-6 border border-blue-200 dark:border-blue-800">
|
|
<div class="flex items-center mb-4">
|
|
<div class="w-12 h-12 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center mr-4">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600 dark:text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<h2 class="text-xl font-medium text-blue-900 dark:text-blue-100">{{ currentUser.name }}</h2>
|
|
<p class="text-blue-700 dark:text-blue-300">{{ currentUser.email }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-2 gap-4 mb-4">
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg p-4 border border-blue-100 dark:border-blue-900/20">
|
|
<h3 class="text-sm font-medium text-gray-500 dark:text-gray-400 mb-1">Role</h3>
|
|
<p class="text-lg font-semibold text-blue-700 dark:text-blue-400">{{ currentUser.role }}</p>
|
|
</div>
|
|
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg p-4 border border-blue-100 dark:border-blue-900/20">
|
|
<h3 class="text-sm font-medium text-gray-500 dark:text-gray-400 mb-1">Department</h3>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-300">{{ currentUser.department }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-4 border border-gray-200 dark:border-gray-700">
|
|
<div class="flex items-center">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400">Role information has been logged to the browser console. Open Developer Tools (F12) and check the console tab for detailed permission information.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-6">
|
|
<h3 class="text-lg font-medium mb-3">Instructions</h3>
|
|
<ol class="list-decimal list-inside space-y-2 text-gray-700 dark:text-gray-300">
|
|
<li>Press <kbd class="px-2 py-1 bg-gray-100 dark:bg-gray-800 rounded border border-gray-300 dark:border-gray-600 text-sm">F12</kbd> to open Developer Tools</li>
|
|
<li>Navigate to the <strong>Console</strong> tab</li>
|
|
<li>View your detailed role and permissions information</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div class="mt-6 flex justify-end">
|
|
<NuxtLink to="/dms" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors">
|
|
Back to DMS
|
|
</NuxtLink>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</rs-card>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.check-role-page {
|
|
height: calc(100vh - 64px);
|
|
}
|
|
|
|
kbd {
|
|
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
}
|
|
</style> |