Update dashboard permissions
This commit is contained in:
parent
8a8b21ba85
commit
3879f698d1
@ -3,7 +3,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/api/call/:phone",
|
path: "/api/call/:phone",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.CALL,
|
||||||
type: "post",
|
type: "post",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const { phone } = request.params;
|
const { phone } = request.params;
|
||||||
|
@ -3,7 +3,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/api/contacts/:phone",
|
path: "/api/contacts/:phone",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.CONTACTS,
|
||||||
type: "post",
|
type: "post",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const { phone } = request.params;
|
const { phone } = request.params;
|
||||||
|
@ -3,7 +3,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/api/contacts/:phone",
|
path: "/api/contacts/:phone",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.CONTACTS,
|
||||||
type: "delete",
|
type: "delete",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const { phone } = request.params;
|
const { phone } = request.params;
|
||||||
|
@ -3,7 +3,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/api/users/:username",
|
path: "/api/users/:username",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.USERS | permissionBits.ADMIN,
|
||||||
type: "post",
|
type: "post",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const { username } = request.params;
|
const { username } = request.params;
|
||||||
|
@ -3,7 +3,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/api/users/:username",
|
path: "/api/users/:username",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.USERS | permissionBits.ADMIN,
|
||||||
type: "delete",
|
type: "delete",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const { username } = request.params;
|
const { username } = request.params;
|
||||||
|
@ -3,7 +3,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/api/users/:username",
|
path: "/api/users/:username",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.DEFAULT,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const { username } = request.params;
|
const { username } = request.params;
|
||||||
|
@ -5,7 +5,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/dashboard/contacts/create",
|
path: "/dashboard/contacts/create",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.CONTACTS | permissionBits.ADMIN,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response, args) {
|
async execute(request, response, args) {
|
||||||
let res = await readFile(
|
let res = await readFile(
|
||||||
|
@ -5,7 +5,7 @@ import { navbar } from '../../../../../utils/navbar.js';
|
|||||||
export default {
|
export default {
|
||||||
path: "/dashboard/contacts",
|
path: "/dashboard/contacts",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.CONTACTS | permissionBits.ADMIN,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const html = await readFile(`${process.env.WWW}/dashboard/contacts/index.html`);
|
const html = await readFile(`${process.env.WWW}/dashboard/contacts/index.html`);
|
||||||
|
@ -5,7 +5,7 @@ import { permissionBits, checkPermissions } from '../../../../../utils/permissio
|
|||||||
export default {
|
export default {
|
||||||
path: "/dashboard/contacts/list",
|
path: "/dashboard/contacts/list",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.CONTACTS | permissionBits.ADMIN,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const contactList = await global.database.contacts.findAll();
|
const contactList = await global.database.contacts.findAll();
|
||||||
|
@ -5,7 +5,7 @@ import { permissionBits } from "../../../../../utils/permissions.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/dashboard/users/create",
|
path: "/dashboard/users/create",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.USERS | permissionBits.ADMIN,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response, args) {
|
async execute(request, response, args) {
|
||||||
let res = await readFile(
|
let res = await readFile(
|
||||||
|
@ -5,7 +5,7 @@ import { navbar } from '../../../../../utils/navbar.js';
|
|||||||
export default {
|
export default {
|
||||||
path: "/dashboard/users",
|
path: "/dashboard/users",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.USERS | permissionBits.ADMIN,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const html = await readFile(`${process.env.WWW}/dashboard/users/index.html`);
|
const html = await readFile(`${process.env.WWW}/dashboard/users/index.html`);
|
||||||
|
@ -5,7 +5,7 @@ import { permissionBits, checkPermissions } from '../../../../../utils/permissio
|
|||||||
export default {
|
export default {
|
||||||
path: "/dashboard/users/list",
|
path: "/dashboard/users/list",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.USERS | permissionBits.ADMIN,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const userList = await global.database.users.findAll();
|
const userList = await global.database.users.findAll();
|
||||||
|
@ -8,7 +8,7 @@ import { navbar } from "../../../../../utils/navbar.js";
|
|||||||
export default {
|
export default {
|
||||||
path: "/dashboard/users/:username",
|
path: "/dashboard/users/:username",
|
||||||
requiresLogin: true,
|
requiresLogin: true,
|
||||||
permissions: permissionBits.ADMIN,
|
permissions: permissionBits.USERS | permissionBits.ADMIN,
|
||||||
type: "get",
|
type: "get",
|
||||||
async execute(request, response) {
|
async execute(request, response) {
|
||||||
const { username } = request.params;
|
const { username } = request.params;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
const permissionBits = {
|
const permissionBits = {
|
||||||
DEFAULT: 1, // 0001
|
DEFAULT: 1, // 00001
|
||||||
CALL: 2, // 0010
|
CALL: 2, // 00010
|
||||||
UNUSED: 4, // 0100
|
USERS: 4, // 00100
|
||||||
ADMIN: 8, // 1000
|
ADMIN: 8, // 01000
|
||||||
|
CONTACTS: 16, // 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPermissions(userPermissionBits) {
|
function checkPermissions(userPermissionBits) {
|
||||||
@ -10,8 +11,9 @@ function checkPermissions(userPermissionBits) {
|
|||||||
let permissions = {
|
let permissions = {
|
||||||
default: false,
|
default: false,
|
||||||
call: false,
|
call: false,
|
||||||
unused: false,
|
users: false,
|
||||||
admin: false,
|
admin: false,
|
||||||
|
contacts: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(userPermissionBits & permissionBits.DEFAULT) {
|
if(userPermissionBits & permissionBits.DEFAULT) {
|
||||||
@ -20,12 +22,15 @@ function checkPermissions(userPermissionBits) {
|
|||||||
if(userPermissionBits & permissionBits.CALL) {
|
if(userPermissionBits & permissionBits.CALL) {
|
||||||
permissions.call = true;
|
permissions.call = true;
|
||||||
}
|
}
|
||||||
if(userPermissionBits & permissionBits.UNUSED) {
|
if(userPermissionBits & permissionBits.USERS) {
|
||||||
permissions.unused = true;
|
permissions.users = true;
|
||||||
}
|
}
|
||||||
if(userPermissionBits & permissionBits.ADMIN) {
|
if(userPermissionBits & permissionBits.ADMIN) {
|
||||||
permissions.admin = true;
|
permissions.admin = true;
|
||||||
}
|
}
|
||||||
|
if(userPermissionBits & permissionBits.CONTACTS) {
|
||||||
|
permissions.contacts = true;
|
||||||
|
}
|
||||||
return permissions;
|
return permissions;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -104,7 +104,7 @@ a {
|
|||||||
<NAVBAR>
|
<NAVBAR>
|
||||||
<form action="javascript:createContactFromForm()" id="contactCreateForm">
|
<form action="javascript:createContactFromForm()" id="contactCreateForm">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Création de compte</h1>
|
<h1>Création de contact</h1>
|
||||||
<p>Formulaire d'ajout de contact.</p>
|
<p>Formulaire d'ajout de contact.</p>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
@ -126,10 +126,14 @@ a {
|
|||||||
<input type="checkbox" name="permissions" value="2">
|
<input type="checkbox" name="permissions" value="2">
|
||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
</label>
|
</label>
|
||||||
<!--<label class="container">Unused
|
<label class="container">Gestion des utilisateurs
|
||||||
<input type="checkbox">
|
<input type="checkbox" name="permissions" value="4">
|
||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
</label>-->
|
</label>
|
||||||
|
<label class="container">Gestion des contacts
|
||||||
|
<input type="checkbox" name="permissions" value="16">
|
||||||
|
<span class="checkmark"></span>
|
||||||
|
</label>
|
||||||
<label class="container">Admin
|
<label class="container">Admin
|
||||||
<input type="checkbox" name="permissions" value="8">
|
<input type="checkbox" name="permissions" value="8">
|
||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
|
Loading…
Reference in New Issue
Block a user