Archived
DEV_
This commit is contained in:
1 parent
9764132760
commit
3e2ff38897
22 files changed
+1193
-63
No files matched your search
@@ -17,6 +17,7 @@ var signoutRouter = require('./routes/signout');
|
|||||||
var getRouter = require('./routes/get');
|
var getRouter = require('./routes/get');
|
||||||
var setRouter = require('./routes/set');
|
var setRouter = require('./routes/set');
|
||||||
var uploadRouter = require('./routes/upload');
|
var uploadRouter = require('./routes/upload');
|
||||||
|
var userManagerRouter = require('./routes/usermanager');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ app.use('/signout', signoutRouter);
|
|||||||
app.use('/get', getRouter);
|
app.use('/get', getRouter);
|
||||||
app.use('/set', setRouter)
|
app.use('/set', setRouter)
|
||||||
app.use('/upload', uploadRouter)
|
app.use('/upload', uploadRouter)
|
||||||
|
app.use('/usermanager', userManagerRouter)
|
||||||
|
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
|
|||||||
+132
-11
@@ -2,8 +2,14 @@ var fs = require("fs")
|
|||||||
var uuid = require('uuid')
|
var uuid = require('uuid')
|
||||||
var path = require("path")
|
var path = require("path")
|
||||||
var CryptoJS = require("crypto-js")
|
var CryptoJS = require("crypto-js")
|
||||||
|
var Jimp = require("jimp")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.createUser = (name, password, level, fullname) => {
|
||||||
|
|
||||||
|
if(this.getUUID(name) == false) {
|
||||||
|
|
||||||
module.exports.createUser = (name, password) => {
|
|
||||||
|
|
||||||
const passcrypt = CryptoJS.AES.encrypt(password, "D*G-KaPdSgVkYp3s");
|
const passcrypt = CryptoJS.AES.encrypt(password, "D*G-KaPdSgVkYp3s");
|
||||||
const userUUID = uuid.v4();
|
const userUUID = uuid.v4();
|
||||||
@@ -11,14 +17,65 @@ module.exports.createUser = (name, password) => {
|
|||||||
"username":name,
|
"username":name,
|
||||||
"password": passcrypt.toString(),
|
"password": passcrypt.toString(),
|
||||||
"uuid": userUUID,
|
"uuid": userUUID,
|
||||||
|
"fullname": fullname,
|
||||||
|
"permissionLevel":level,
|
||||||
"token":{
|
"token":{
|
||||||
|
|
||||||
|
|
||||||
}
|
},
|
||||||
|
"lastconnexion":0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const src = __dirname + path.sep + "public" + path.sep + "images" + path.sep + "standalone.png"
|
||||||
|
const dest = __dirname + path.sep + "public" + path.sep + "images" + path.sep + "userspics" + path.sep + name + ".png"
|
||||||
|
|
||||||
|
fs.copyFileSync(src, dest)
|
||||||
fs.writeFileSync(__dirname + path.sep + "users" + path.sep + userUUID + ".json", JSON.stringify(userData, null, 2))
|
fs.writeFileSync(__dirname + path.sep + "users" + path.sep + userUUID + ".json", JSON.stringify(userData, null, 2))
|
||||||
|
|
||||||
|
return "USER_CREATED"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return "USER_ALREADY_EXIST"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.deleteUser = (name) => {
|
||||||
|
|
||||||
|
const userUUID = this.getUUID(name)
|
||||||
|
|
||||||
|
if(userUUID != false) {
|
||||||
|
|
||||||
|
|
||||||
|
fs.rmSync(__dirname + path.sep + "users" + path.sep + userUUID + ".json")
|
||||||
|
fs.rmSync(__dirname + path.sep + "public" + path.sep + "images" + path.sep + "userspics"+ path.sep + name+ ".png")
|
||||||
|
|
||||||
|
return "USER_DELETED"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return "USER_ALREADY_DELETED"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.deleteToken = (username) => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(username) + ".json", 'utf-8'))
|
||||||
|
|
||||||
|
userData.token = {}
|
||||||
|
|
||||||
|
fs.writeFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(username) + ".json", JSON.stringify(userData, null, 2))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.checkToken = (req, res) => {
|
module.exports.checkToken = (req, res) => {
|
||||||
@@ -27,15 +84,21 @@ module.exports.checkToken = (req, res) => {
|
|||||||
const users = this.getUsers()
|
const users = this.getUsers()
|
||||||
|
|
||||||
if(req.cookies.tokenID == null) {
|
if(req.cookies.tokenID == null) {
|
||||||
return false;
|
const checkTokenData = {"name":false}
|
||||||
|
return checkTokenData;
|
||||||
|
|
||||||
} else if(tokens.has(req.cookies.tokenID)) {
|
} else if(tokens.has(req.cookies.tokenID)) {
|
||||||
const user = tokens.get(req.cookies.tokenID)
|
const user = tokens.get(req.cookies.tokenID)
|
||||||
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + users.get(user) + ".json", 'utf-8'))
|
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + users.get(user) + ".json", 'utf-8'))
|
||||||
|
|
||||||
|
userData.lastconnexion = Date.now()
|
||||||
|
|
||||||
|
fs.writeFileSync(__dirname + path.sep + "users" + path.sep + userData.uuid + ".json", JSON.stringify(userData, null, 2))
|
||||||
|
|
||||||
if(userData.token.livableToken == true) {
|
if(userData.token.livableToken == true) {
|
||||||
|
|
||||||
return user;
|
const checkTokenData = {"name":user, "permLevel": userData.permissionLevel, "fullname":userData.fullname, "lastconnexion":userData.lastconnexion};
|
||||||
|
return checkTokenData;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const tokenDate = new Date(userData.token.createdAt)
|
const tokenDate = new Date(userData.token.createdAt)
|
||||||
@@ -43,11 +106,13 @@ module.exports.checkToken = (req, res) => {
|
|||||||
|
|
||||||
if(tokenDate.getDay() == nowDate.getDay() && tokenDate.getMonth() == nowDate.getMonth()) {
|
if(tokenDate.getDay() == nowDate.getDay() && tokenDate.getMonth() == nowDate.getMonth()) {
|
||||||
|
|
||||||
return user;
|
const checkTokenData = {"name":user, "permLevel": userData.permissionLevel, "fullname":userData.fullname, "lastconnexion":userData.lastconnexion};
|
||||||
|
return checkTokenData;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
res.clearCookie('tokenID');
|
res.clearCookie('tokenID');
|
||||||
return false;
|
const checkTokenData = {"name":false}
|
||||||
|
return checkTokenData;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -55,16 +120,20 @@ module.exports.checkToken = (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
const checkTokenData = {"name":false}
|
||||||
|
return checkTokenData;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getFullName = (username) => {
|
module.exports.getFullName = (username) => {
|
||||||
|
|
||||||
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(username) + ".json", 'utf-8'))
|
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(username) + ".json", 'utf-8'))
|
||||||
|
|
||||||
|
|
||||||
return userData.fullname
|
return userData.fullname
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -136,13 +205,23 @@ module.exports.getUUID = (username) => {
|
|||||||
users.set(fileData.username, fileData.uuid)
|
users.set(fileData.username, fileData.uuid)
|
||||||
|
|
||||||
})
|
})
|
||||||
return users.get(username);
|
|
||||||
|
var data = users.get(username);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(typeof data == "undefined") {
|
||||||
|
|
||||||
|
data = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.changeFullName = (username, req, res) => {
|
module.exports.changeFullName = (username, req, res) => {
|
||||||
|
|
||||||
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(this.checkToken(req, res)) + ".json", 'utf-8'))
|
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(this.checkToken(req, res).name) + ".json", 'utf-8'))
|
||||||
|
|
||||||
Object.defineProperties(userData, {
|
Object.defineProperties(userData, {
|
||||||
fullname: {
|
fullname: {
|
||||||
@@ -187,7 +266,7 @@ module.exports.changePassword = (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(this.checkToken(req, res)) + ".json", 'utf-8'))
|
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(this.checkToken(req, res).name) + ".json", 'utf-8'))
|
||||||
|
|
||||||
const oldp = CryptoJS.AES.encrypt(req.body.additional, "D*G-KaPdSgVkYp3s")
|
const oldp = CryptoJS.AES.encrypt(req.body.additional, "D*G-KaPdSgVkYp3s")
|
||||||
const newp = CryptoJS.AES.encrypt(req.body.value, "D*G-KaPdSgVkYp3s")
|
const newp = CryptoJS.AES.encrypt(req.body.value, "D*G-KaPdSgVkYp3s")
|
||||||
@@ -217,3 +296,45 @@ module.exports.changePassword = (req, res) => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.getAll = (username) => {
|
||||||
|
|
||||||
|
const users = this.getUsers()
|
||||||
|
|
||||||
|
|
||||||
|
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + users.get(username) + ".json", 'utf-8'))
|
||||||
|
const allData = {"username":username, "permLevel": userData.permissionLevel, "fullname":userData.fullname, "lastconnexion":userData.lastconnexion};
|
||||||
|
return allData
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.editUser = (requestData) => {
|
||||||
|
|
||||||
|
if(this.getUUID(requestData.original) != false) {
|
||||||
|
|
||||||
|
const userData = JSON.parse(fs.readFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(requestData.original) + ".json", 'utf-8'))
|
||||||
|
|
||||||
|
userData.token = {};
|
||||||
|
userData.username = requestData.username;
|
||||||
|
userData.fullname = requestData.fullname;
|
||||||
|
userData.permissionLevel = requestData.permLevel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(requestData.password != "") {
|
||||||
|
|
||||||
|
userData.password = CryptoJS.AES.encrypt(requestData.password, "D*G-KaPdSgVkYp3s").toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fs.renameSync(__dirname + path.sep + "public" + path.sep + "images" + path.sep + "userspics" + path.sep + requestData.original + ".png",__dirname + path.sep + "public" + path.sep + "images" + path.sep + "userspics" + path.sep + requestData.username + ".png")
|
||||||
|
fs.writeFileSync(__dirname + path.sep + "users" + path.sep + this.getUUID(requestData.original) + ".json", JSON.stringify(userData, null, 2))
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "neutral",
|
"name": "neutral",
|
||||||
"version": "DEV_2.0",
|
"version": "DEV_3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
"ext": "js",
|
"ext": "js",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 17 KiB |
@@ -1,2 +1,2 @@
|
|||||||
/*! For license information please see neutron.bundle.js.LICENSE.txt */
|
/*! For license information please see neutron.bundle.js.LICENSE.txt */
|
||||||
(()=>{var e={466:(e,n,t)=>{"use strict";t.d(n,{Z:()=>H});var o=t(81),r=t.n(o),a=t(645),i=t.n(a),f=t(667),s=t.n(f),c=new URL(t(770),t.b),l=new URL(t(199),t.b),d=new URL(t(204),t.b),b=new URL(t(931),t.b),p=new URL(t(486),t.b),m=new URL(t(609),t.b),g=new URL(t(469),t.b),u=new URL(t(122),t.b),h=new URL(t(144),t.b),v=new URL(t(217),t.b),x=new URL(t(956),t.b),w=new URL(t(460),t.b),y=new URL(t(740),t.b),k=new URL(t(254),t.b),_=new URL(t(647),t.b),T=new URL(t(692),t.b),A=i()(r()),C=s()(c),E=s()(l),z=s()(d),j=s()(b),S=s()(p),q=s()(m),L=s()(g),D=s()(u),O=s()(h),N=s()(v),F=s()(x),I=s()(w),M=s()(y),P=s()(k),$=s()(_),U=s()(T);A.push([e.id,'/*!\n * Bootstrap v5.2.3 (https://getbootstrap.com/)\n * Copyright 2011-2022 The Bootstrap Authors\n * Copyright 2011-2022 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n */:root{--bs-blue: #0d6efd;--bs-indigo: #6610f2;--bs-purple: #6f42c1;--bs-pink: #d63384;--bs-red: #dc3545;--bs-orange: #fd7e14;--bs-yellow: #ffc107;--bs-green: #198754;--bs-teal: #20c997;--bs-cyan: #0dcaf0;--bs-black: #000;--bs-white: #fff;--bs-gray: #6c757d;--bs-gray-dark: #343a40;--bs-gray-100: #f8f9fa;--bs-gray-200: #e9ecef;--bs-gray-300: #dee2e6;--bs-gray-400: #ced4da;--bs-gray-500: #adb5bd;--bs-gray-600: #6c757d;--bs-gray-700: #495057;--bs-gray-800: #343a40;--bs-gray-900: #212529;--bs-primary: #0d6efd;--bs-secondary: #6c757d;--bs-success: #198754;--bs-info: #0dcaf0;--bs-warning: #ffc107;--bs-danger: #dc3545;--bs-light: #f8f9fa;--bs-dark: #212529;--bs-primary-rgb: 13, 110, 253;--bs-secondary-rgb: 108, 117, 125;--bs-success-rgb: 25, 135, 84;--bs-info-rgb: 13, 202, 240;--bs-warning-rgb: 255, 193, 7;--bs-danger-rgb: 220, 53, 69;--bs-light-rgb: 248, 249, 250;--bs-dark-rgb: 33, 37, 41;--bs-white-rgb: 255, 255, 255;--bs-black-rgb: 0, 0, 0;--bs-body-color-rgb: 33, 37, 41;--bs-body-bg-rgb: 255, 255, 255;--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));--bs-body-font-family: var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight: 400;--bs-body-line-height: 1.5;--bs-body-color: #212529;--bs-body-bg: #fff;--bs-border-width: 1px;--bs-border-style: solid;--bs-border-color: #dee2e6;--bs-border-color-translucent: rgba(0, 0, 0, 0.175);--bs-border-radius: 0.375rem;--bs-border-radius-sm: 0.25rem;--bs-border-radius-lg: 0.5rem;--bs-border-radius-xl: 1rem;--bs-border-radius-2xl: 2rem;--bs-border-radius-pill: 50rem;--bs-link-color: #0d6efd;--bs-link-hover-color: #0a58ca;--bs-code-color: #d63384;--bs-highlight-bg: #fff3cd}*,*::before,*::after{box-sizing:border-box}@media(prefers-reduced-motion: no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0)}hr{margin:1rem 0;color:inherit;border:0;border-top:1px solid;opacity:.25}h6,.h6,h5,.h5,h4,.h4,h3,.h3,h2,.h2,h1,.h1{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1,.h1{font-size:calc(1.375rem + 1.5vw)}@media(min-width: 1200px){h1,.h1{font-size:2.5rem}}h2,.h2{font-size:calc(1.325rem + 0.9vw)}@media(min-width: 1200px){h2,.h2{font-size:2rem}}h3,.h3{font-size:calc(1.3rem + 0.6vw)}@media(min-width: 1200px){h3,.h3{font-size:1.75rem}}h4,.h4{font-size:calc(1.275rem + 0.3vw)}@media(min-width: 1200px){h4,.h4{font-size:1.5rem}}h5,.h5{font-size:1.25rem}h6,.h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[title]{text-decoration:underline dotted;cursor:help;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}ol,ul,dl{margin-top:0;margin-bottom:1rem}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small,.small{font-size:0.875em}mark,.mark{padding:.1875em;background-color:var(--bs-highlight-bg)}sub,sup{position:relative;font-size:0.75em;line-height:0;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}a{color:var(--bs-link-color);text-decoration:underline}a:hover{color:var(--bs-link-hover-color)}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}pre,code,kbd,samp{font-family:var(--bs-font-monospace);font-size:1em}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:0.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:0.875em;color:var(--bs-code-color);word-wrap:break-word}a>codeLine truncated
|
(()=>{var e={466:(e,n,t)=>{"use strict";t.d(n,{Z:()=>H});var o=t(81),r=t.n(o),a=t(645),i=t.n(a),f=t(667),s=t.n(f),c=new URL(t(770),t.b),l=new URL(t(199),t.b),d=new URL(t(204),t.b),b=new URL(t(931),t.b),p=new URL(t(486),t.b),m=new URL(t(588),t.b),g=new URL(t(469),t.b),u=new URL(t(122),t.b),h=new URL(t(144),t.b),v=new URL(t(217),t.b),x=new URL(t(956),t.b),w=new URL(t(460),t.b),y=new URL(t(740),t.b),k=new URL(t(254),t.b),_=new URL(t(647),t.b),T=new URL(t(692),t.b),A=i()(r()),C=s()(c),E=s()(l),z=s()(d),j=s()(b),S=s()(p),q=s()(m),L=s()(g),D=s()(u),O=s()(h),N=s()(v),F=s()(x),I=s()(w),M=s()(y),P=s()(k),$=s()(_),U=s()(T);A.push([e.id,'/*!\n * Bootstrap v5.2.3 (https://getbootstrap.com/)\n * Copyright 2011-2022 The Bootstrap Authors\n * Copyright 2011-2022 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n */:root{--bs-blue: #0d6efd;--bs-indigo: #6610f2;--bs-purple: #6f42c1;--bs-pink: #d63384;--bs-red: #dc3545;--bs-orange: #fd7e14;--bs-yellow: #ffc107;--bs-green: #198754;--bs-teal: #20c997;--bs-cyan: #0dcaf0;--bs-black: #000;--bs-white: #fff;--bs-gray: #6c757d;--bs-gray-dark: #343a40;--bs-gray-100: #f8f9fa;--bs-gray-200: #e9ecef;--bs-gray-300: #dee2e6;--bs-gray-400: #ced4da;--bs-gray-500: #adb5bd;--bs-gray-600: #6c757d;--bs-gray-700: #495057;--bs-gray-800: #343a40;--bs-gray-900: #212529;--bs-primary: #0d6efd;--bs-secondary: #6c757d;--bs-success: #198754;--bs-info: #0dcaf0;--bs-warning: #ffc107;--bs-danger: #dc3545;--bs-light: #f8f9fa;--bs-dark: #212529;--bs-primary-rgb: 13, 110, 253;--bs-secondary-rgb: 108, 117, 125;--bs-success-rgb: 25, 135, 84;--bs-info-rgb: 13, 202, 240;--bs-warning-rgb: 255, 193, 7;--bs-danger-rgb: 220, 53, 69;--bs-light-rgb: 248, 249, 250;--bs-dark-rgb: 33, 37, 41;--bs-white-rgb: 255, 255, 255;--bs-black-rgb: 0, 0, 0;--bs-body-color-rgb: 33, 37, 41;--bs-body-bg-rgb: 255, 255, 255;--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));--bs-body-font-family: var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight: 400;--bs-body-line-height: 1.5;--bs-body-color: #212529;--bs-body-bg: #fff;--bs-border-width: 1px;--bs-border-style: solid;--bs-border-color: #dee2e6;--bs-border-color-translucent: rgba(0, 0, 0, 0.175);--bs-border-radius: 0.375rem;--bs-border-radius-sm: 0.25rem;--bs-border-radius-lg: 0.5rem;--bs-border-radius-xl: 1rem;--bs-border-radius-2xl: 2rem;--bs-border-radius-pill: 50rem;--bs-link-color: #0d6efd;--bs-link-hover-color: #0a58ca;--bs-code-color: #d63384;--bs-highlight-bg: #fff3cd}*,*::before,*::after{box-sizing:border-box}@media(prefers-reduced-motion: no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0)}hr{margin:1rem 0;color:inherit;border:0;border-top:1px solid;opacity:.25}h6,.h6,h5,.h5,h4,.h4,h3,.h3,h2,.h2,h1,.h1{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1,.h1{font-size:calc(1.375rem + 1.5vw)}@media(min-width: 1200px){h1,.h1{font-size:2.5rem}}h2,.h2{font-size:calc(1.325rem + 0.9vw)}@media(min-width: 1200px){h2,.h2{font-size:2rem}}h3,.h3{font-size:calc(1.3rem + 0.6vw)}@media(min-width: 1200px){h3,.h3{font-size:1.75rem}}h4,.h4{font-size:calc(1.275rem + 0.3vw)}@media(min-width: 1200px){h4,.h4{font-size:1.5rem}}h5,.h5{font-size:1.25rem}h6,.h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[title]{text-decoration:underline dotted;cursor:help;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}ol,ul,dl{margin-top:0;margin-bottom:1rem}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small,.small{font-size:0.875em}mark,.mark{padding:.1875em;background-color:var(--bs-highlight-bg)}sub,sup{position:relative;font-size:0.75em;line-height:0;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}a{color:var(--bs-link-color);text-decoration:underline}a:hover{color:var(--bs-link-hover-color)}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}pre,code,kbd,samp{font-family:var(--bs-font-monospace);font-size:1em}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:0.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:0.875em;color:var(--bs-code-color);word-wrap:break-word}a>codeLine truncated
|
||||||
@@ -288,7 +288,7 @@ body {
|
|||||||
.sidebar-content {
|
.sidebar-content {
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
height: 85%;
|
height: 83%;
|
||||||
padding-top: 50%;
|
padding-top: 50%;
|
||||||
padding-bottom: 50%;
|
padding-bottom: 50%;
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ body {
|
|||||||
|
|
||||||
.sidebar-footer {
|
.sidebar-footer {
|
||||||
|
|
||||||
height: 5%;
|
height: 10%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -328,12 +328,13 @@ body {
|
|||||||
vertical-align: center;
|
vertical-align: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
transform: scale(1.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:hover .sidebar-image {
|
.sidebar:hover .sidebar-image {
|
||||||
|
|
||||||
display: unset;
|
display: unset;
|
||||||
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="hbox col-lg">
|
<div class="hbox col-lg">
|
||||||
<h1>EcoleDirecte</h1>
|
<h1>EcoleDirecte</h1>
|
||||||
|
<!-- <iframe width="100%" height="90%" src="https://ecoledirecte.com"></iframe> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row w-100">
|
<div class="row w-100">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div class="home">
|
<div class="settings">
|
||||||
<h1>Paramètres du compte</h1>
|
<h1>Paramètres du compte</h1>
|
||||||
</br>
|
</br>
|
||||||
<div class="homepanel">
|
<div class="homepanel">
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(user_oldp.value != "" | user_newp.value != "") {
|
if(user_oldp.value != "" | user_newp.value != "") {
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+759
-6
@@ -1,33 +1,655 @@
|
|||||||
<div class="home">
|
<div class="users">
|
||||||
<h1>Gestion des utilisateurs</h1>
|
<h1>Gestionnnaire des utilisateurs</h1>
|
||||||
</br>
|
</br>
|
||||||
<div class="homepanel">
|
<div class="homepanel">
|
||||||
<div class="row w-100">
|
<div class="row w-100">
|
||||||
<div class="hbox col">
|
<div class="hbox col">
|
||||||
|
|
||||||
|
|
||||||
<h1><i class="fa fa-users"></i> Utilisateurs</h1>
|
<h1><i class="fa fa-users"></i> Utilisateurs</h1>
|
||||||
|
<div id="gus_panel" class="gus_users">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<button id="gus_add" class="gus_add"><i class="fa fa-plus"></i> Ajouter un utilisateur</button>
|
||||||
|
<div id="gus_info"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<dialog class="gus_adduser" id="gus_adduser">
|
||||||
|
<h1><i class="fa fa-plus"></i> Ajouter un utilisateur</h1>
|
||||||
|
<div class="gus_add_imagediv">
|
||||||
|
<img width="200" height="200" id="gus_add_image" class="gus_add_image" src="/images/standalone.png">
|
||||||
|
<br>
|
||||||
|
<input class="gus_image_upload" accept="image/png, image/jpeg" name="apic" type="file" id="gus_image_upload"/>
|
||||||
|
<br>
|
||||||
|
<div style="color: rgb(255, 76, 76);" id="gus_add_image_info"></div>
|
||||||
|
</div>
|
||||||
|
<div class="form">
|
||||||
|
<p>Nom d'utilisateur</p>
|
||||||
|
<input class="inp" id="gus_add_username" type="text">
|
||||||
|
<p>Nom complet :</p>
|
||||||
|
<input class="inp" id="gus_add_fullname" type="text">
|
||||||
|
<p>Mot de passe :</p>
|
||||||
|
<input class="inp" id="gus_add_password" type="password">
|
||||||
|
<p>Niveau de permission :</p>
|
||||||
|
<select class="inp" id="gus_add_perm">
|
||||||
|
<option>Niveau 1 : (Utilisateur)</option>
|
||||||
|
<option>Niveau 2 : (Editeur)</option>
|
||||||
|
<option>Niveau 3 : (Operateur)</option>
|
||||||
|
<option>Niveau 4 : (Administrateur)</option>
|
||||||
|
</select>
|
||||||
|
<div style="color: rgb(255, 76, 76);" id="gus_add_info"></div>
|
||||||
|
</div>
|
||||||
|
<button onclick="getPage('users.html')" id="gus_add_close" class="gus_add_close">Annuler</button>
|
||||||
|
<button id="gus_add_confirm" class="gus_add_confirm">Ajouter</button>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="gus_dialoguser">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
if(typeof adduserform == 'undefined'){
|
||||||
|
|
||||||
|
const panel = document.getElementById("gus_panel")
|
||||||
|
const dialogUserall = document.getElementById("gus_dialoguser")
|
||||||
|
|
||||||
|
showUsers()
|
||||||
|
|
||||||
|
/* EXAMPLE OF A LINE
|
||||||
|
|
||||||
|
<div class="gus_line row w-100">
|
||||||
|
<div class="col-lg">
|
||||||
|
<p><img width="200" class="gus_image" src="images/userspics/' + user + '.png"> <span id="' + user + "_fullname" + '"></span></p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg">
|
||||||
|
<p>Dernière connexion : <span id="' + user + "_lastco" + '"></span></p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg">
|
||||||
|
<p>Niveau de permissions : <span id="' + user + "_permLevel" + '"></span></p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg">
|
||||||
|
<button id="' + user + "_edit" + '" class="gus_edit"><i class="fa fa-pen"></i></button>
|
||||||
|
<button id="' + user + "_deco" + '" class="gus_signout"><i class="fa-solid fa-arrow-right-from-bracket"></i></button>
|
||||||
|
<button id="' + user + "_del" + '" class="gus_delete"><i class="fa fa-trash"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showUsers() {
|
||||||
|
|
||||||
|
var number = Date.now()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var dialogtoshow = new Array()
|
||||||
|
var usertoshow = new Array()
|
||||||
|
|
||||||
|
fetch('/usermanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"get", "value": ""})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => load(response))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function load(response) {
|
||||||
|
|
||||||
|
if(response.result == "failed") {
|
||||||
|
content.innerHTML = ' <h1 style="color:red;"><i style="color:yellow; font-size: 2vw;" class="fa fa-warning"></i> Erreur de chargement des données - Erreur : ' + response.content + '</h1>'
|
||||||
|
console.log("FAILED")
|
||||||
|
|
||||||
|
} else if(response.result == "success") {
|
||||||
|
|
||||||
|
var fullname;
|
||||||
|
var lastco;
|
||||||
|
var permLevel;
|
||||||
|
|
||||||
|
for(var user of response.content) {
|
||||||
|
|
||||||
|
|
||||||
|
usertoshow.push('<div class="gus_line row w-100"><div class="col-lg"><p><img width="200" class="gus_image" src="images/userspics/'+ user +'.png?' + number + '"> <span id="' + user + "_fullname"+'"></span></p></div><div class="col-lg"><p>Dernière connexion : <span id="' + user + "_lastco"+'"></span></p></div><div class="col-lg"><p>Niveau de permissions : <span id="'+user+"_permLevel"+'"></span></p></div><div class="col-lg"><button id="'+user+"_edit"+'" class="gus_edit"><i class="fa fa-pen"></i></button><button id="'+user+"_deco"+'" class="gus_signout"><i class="fa-solid fa-arrow-right-from-bracket"></i></button><button id="'+user+"_del"+'" class="gus_delete"><i class="fa fa-trash"></i></button></div></div>')
|
||||||
|
dialogtoshow.push('<dialog class="gus_adduser" id="' + user + '_editDialog"> <h1><i class="fa fa-pen"></i> Editer un utilisateur</h1> <div class="gus_add_imagediv"> <img width="200" height="200" id="gus_add_image" class="gus_add_image" src="/images/userspics/' + user + '.png?' + number + '"> <br> <input class="gus_image_upload" accept="image/png, image/jpeg" name="apic" type="file" id="' + user + '_image_upload"/> <br> <div style="color: rgb(255, 76, 76);" id="' + user + '_add_image_info"></div> </div> <div class="form"> <p>Nom d\'utilisateur</p> <input class="inp" id="' + user + '_add_username" type="text"> <p>Nom complet :</p> <input class="inp" id="' + user + '_add_fullname" type="text"> <p>Mot de passe :</p> <input class="inp" id="' + user + '_add_password" type="password"> <p>Niveau de permission :</p> <select class="inp" id="' + user + '_add_perm"> <option>Niveau 1 : (Utilisateur)</option> <option>Niveau 2 : (Editeur)</option> <option>Niveau 3 : (Operateur)</option> <option>Niveau 4 : (Administrateur)</option> </select> <div style="color: rgb(255, 76, 76);" id="' + user + '_add_info"></div> </div> <button onclick="getPage(\'users.html\')" id="' + user + '_add_close" class="gus_add_close">Annuler</button> <button id="' + user + '_add_confirm" class="gus_add_confirm">Editer</button> </dialog> ')
|
||||||
|
|
||||||
|
panel.innerHTML = usertoshow.join("")
|
||||||
|
dialogUserall.innerHTML = dialogtoshow.join("")
|
||||||
|
|
||||||
|
|
||||||
|
fetch('/get', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"all", "name": user, "additional": ""})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => after(response))
|
||||||
|
|
||||||
|
|
||||||
|
function after(response) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const date = new Date(response.content.lastconnexion)
|
||||||
|
|
||||||
|
var gmonth = date.getMonth()
|
||||||
|
var gday = date.getDate()
|
||||||
|
var gHour = date.getHours()
|
||||||
|
var gMinute = date.getMinutes()
|
||||||
|
var gSecondes = date.getSeconds()
|
||||||
|
|
||||||
|
|
||||||
|
if(date.getMonth() + 1 <= 9) {
|
||||||
|
gmonth = "0" + (date.getMonth() + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(date.getDate() + 1 <= 9) {
|
||||||
|
gday = "0" + date.getDate()
|
||||||
|
}
|
||||||
|
|
||||||
|
if(date.getHours() + 1 <= 9) {
|
||||||
|
gHour = "0" + date.getHours()
|
||||||
|
}
|
||||||
|
|
||||||
|
if(date.getMinutes() + 1 <= 9) {
|
||||||
|
gMinute = "0" + date.getMinutes()
|
||||||
|
}
|
||||||
|
|
||||||
|
if(date.getSeconds() + 1 <= 9) {
|
||||||
|
gSecondes = "0" + date.getSeconds()
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentDate = gday + "-" + gmonth + "-" + date.getFullYear() + " - " + gHour + ":" + gMinute
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fullname = document.getElementById(response.content.username + "_fullname")
|
||||||
|
lastco = document.getElementById(response.content.username + "_lastco")
|
||||||
|
permLevel = document.getElementById(response.content.username + "_permLevel")
|
||||||
|
|
||||||
|
fullname.innerHTML = response.content.fullname
|
||||||
|
permLevel.innerHTML = response.content.permLevel
|
||||||
|
lastco.innerHTML = currentDate
|
||||||
|
|
||||||
|
const editBtn = document.getElementById(response.content.username + "_edit")
|
||||||
|
const decoBtn = document.getElementById(response.content.username +"_deco")
|
||||||
|
const delBtn = document.getElementById(response.content.username + "_del")
|
||||||
|
|
||||||
|
delBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
fetch('/usermanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"del", "value": response.content.username})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
getPage("users.html")
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
decoBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
fetch('/usermanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"deco", "value": response.content.username})
|
||||||
|
})
|
||||||
|
|
||||||
|
gusInfo.innerHTML = "<p style='color: rgb(130, 255, 163); padding: 1vw;'>Le Token de l'utilisateur <strong>" + response.content.username + "</strong> a été supprimé</p>"
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
editBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
const editDialog = document.getElementById(response.content.username + "_editDialog")
|
||||||
|
|
||||||
|
const edituserUsername = document.getElementById(response.content.username + "_add_username")
|
||||||
|
const edituserPassword = document.getElementById(response.content.username + "_add_password")
|
||||||
|
const edituserFullname = document.getElementById(response.content.username + "_add_fullname")
|
||||||
|
const edituserPerm = document.getElementById(response.content.username + "_add_perm")
|
||||||
|
const edituserInfo = document.getElementById(response.content.username + "_add_info")
|
||||||
|
const edituserImage = document.getElementById(response.content.username + "_image_upload")
|
||||||
|
|
||||||
|
const edituserConfirm = document.getElementById(response.content.username + "_add_confirm")
|
||||||
|
|
||||||
|
edituserUsername.value = response.content.username;
|
||||||
|
edituserFullname.value = response.content.fullname;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(response.content.permLevel == 1) {
|
||||||
|
|
||||||
|
edituserPerm.value = "Niveau 1 : (Utilisateur)";
|
||||||
|
} else if(response.content.permLevel == 2) {
|
||||||
|
|
||||||
|
edituserPerm.value = "Niveau 2 : (Editeur)";
|
||||||
|
} else if(response.content.permLevel == 3) {
|
||||||
|
|
||||||
|
edituserPerm.value = "Niveau 3 : (Operateur)";
|
||||||
|
} else if(response.content.permLevel == 4) {
|
||||||
|
|
||||||
|
edituserPerm.value = "Niveau 4 : (Administrateur)";
|
||||||
|
}
|
||||||
|
|
||||||
|
edituserConfirm.addEventListener("click", () => {
|
||||||
|
|
||||||
|
edituserInfo.innerHTML = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(edituserUsername.value != "" && edituserFullname.value != "") {
|
||||||
|
|
||||||
|
var level = 1;
|
||||||
|
|
||||||
|
if(edituserPerm.value == 'Niveau 1 : (Utilisateur)') {
|
||||||
|
level = 1
|
||||||
|
|
||||||
|
} else if(edituserPerm.value == 'Niveau 2 : (Editeur)') {
|
||||||
|
level = 2
|
||||||
|
|
||||||
|
} else if(edituserPerm.value == 'Niveau 3 : (Operateur)') {
|
||||||
|
level = 3
|
||||||
|
|
||||||
|
} else if(edituserPerm.value == 'Niveau 4 : (Administrateur)') {
|
||||||
|
level = 4
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const requestData = {
|
||||||
|
"original":response.content.username,
|
||||||
|
"username":edituserUsername.value,
|
||||||
|
"fullname":edituserFullname.value,
|
||||||
|
"permLevel": level,
|
||||||
|
"password": edituserPassword.value
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fetch('/usermanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"edit", "value": requestData})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => editresp(response))
|
||||||
|
|
||||||
|
|
||||||
|
function editresp(eresponse) {
|
||||||
|
if(eresponse.result == "failed") {
|
||||||
|
content.innerHTML = ' <h1 style="color:red;"><i style="color:yellow; font-size: 2vw;" class="fa fa-warning"></i> Erreur de chargement des données - Erreur : ' + eresponse.content + '</h1>'
|
||||||
|
console.log("FAILED")
|
||||||
|
|
||||||
|
} else if(eresponse.result == "success") {
|
||||||
|
|
||||||
|
if(eresponse.content != "DATA_VALID") {
|
||||||
|
edituserInfo.innerHTML = "L'édition de l'utilisateur a échoué."
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(edituserImage.files[0] != null) {
|
||||||
|
|
||||||
|
|
||||||
|
const image_acc = new FormData();
|
||||||
|
image_acc.append("apic", edituserImage.files[0])
|
||||||
|
|
||||||
|
fetch('/upload', {
|
||||||
|
method: 'POST',
|
||||||
|
mode:"cors",
|
||||||
|
cache:"no-cache",
|
||||||
|
credentials:"same-origin",
|
||||||
|
headers: {
|
||||||
|
"uploadforuser": requestData.username
|
||||||
|
|
||||||
|
},
|
||||||
|
referrerPolicy:"no-referrer",
|
||||||
|
redirect: 'follow',
|
||||||
|
body: image_acc
|
||||||
|
}).then(response => getPage("users.html"))
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
getPage("users.html")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
edituserInfo.innerHTML = "<p>L'utilisateur ne peut pas ne pas avoir de nom d'utilisateur et de nom complet</p>"
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
editDialog.showModal()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const imgInput = document.getElementById("gus_image_upload")
|
||||||
|
const imgEl = document.getElementById("gus_add_image")
|
||||||
|
const imgInfo = document.getElementById("gus_add_image_info")
|
||||||
|
|
||||||
|
imgInput.addEventListener("change", (event) => {
|
||||||
|
|
||||||
|
imgInfo.innerHTML = ""
|
||||||
|
const nowImage = event.target.files
|
||||||
|
const nowImageLength = event.target.files
|
||||||
|
|
||||||
|
if(nowImage[0].type == "image/jpeg" | nowImage[0].type == "image/png") {
|
||||||
|
const imageSrc = URL.createObjectURL(nowImage[0]);
|
||||||
|
imgEl.src = imageSrc;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
imgInput.value = ""
|
||||||
|
imgInfo.innerHTML = '<p>Seul les images (JPEG et PNG) sont acceptés.</p>'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const adduserForm = document.getElementById("gus_adduser")
|
||||||
|
const adduserBtn = document.getElementById("gus_add")
|
||||||
|
const adduserConfirm = document.getElementById("gus_add_confirm")
|
||||||
|
|
||||||
|
const adduserUsername = document.getElementById("gus_add_username")
|
||||||
|
const adduserPassword = document.getElementById("gus_add_password")
|
||||||
|
const adduserFullname = document.getElementById("gus_add_fullname")
|
||||||
|
const adduserPerm = document.getElementById("gus_add_perm")
|
||||||
|
const addInfo = document.getElementById("gus_add_info")
|
||||||
|
const gusInfo = document.getElementById("gus_info")
|
||||||
|
|
||||||
|
adduserBtn.addEventListener("click", () => {
|
||||||
|
|
||||||
|
adduserUsername.value = ""
|
||||||
|
adduserPassword.value = ""
|
||||||
|
adduserFullname.value = ""
|
||||||
|
adduserPerm.value = "Niveau 1 : (Utilisateur)"
|
||||||
|
addInfo.value = ""
|
||||||
|
gusInfo.innerHTML = ""
|
||||||
|
imgEl.src = "/images/standalone.png" ;
|
||||||
|
|
||||||
|
adduserForm.showModal()
|
||||||
|
})
|
||||||
|
|
||||||
|
adduserConfirm.addEventListener("click", () => {
|
||||||
|
|
||||||
|
addInfo.innerHTML = ""
|
||||||
|
imgInfo.innerHTML = ""
|
||||||
|
|
||||||
|
if(adduserUsername.value != "" && adduserPassword.value != "" && adduserFullname.value != "") {
|
||||||
|
|
||||||
|
const addUserData = {"username":adduserUsername.value, "password":adduserPassword.value, "fullname":adduserFullname.value, "permLevel":adduserPerm.value }
|
||||||
|
|
||||||
|
const addUserImage = document.getElementById("gus_image_upload")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fetch('/usermanager', {
|
||||||
|
method: 'POST',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({"request":"add", "value": addUserData})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => load(response))
|
||||||
|
|
||||||
|
function load(response) {
|
||||||
|
if(response.result == "failed") {
|
||||||
|
content.innerHTML = ' <h1 style="color:red;"><i style="color:yellow; font-size: 2vw;" class="fa fa-warning"></i> Erreur de chargement des données - Erreur : ' + response.content + '</h1>'
|
||||||
|
console.log("FAILED")
|
||||||
|
|
||||||
|
} else if(response.result == "success") {
|
||||||
|
|
||||||
|
if(response.content == "VALID") {
|
||||||
|
|
||||||
|
if(addUserImage.files[0] != null) {
|
||||||
|
|
||||||
|
|
||||||
|
const image_acc = new FormData();
|
||||||
|
image_acc.append("apic", addUserImage.files[0])
|
||||||
|
|
||||||
|
fetch('/upload', {
|
||||||
|
method: 'POST',
|
||||||
|
mode:"cors",
|
||||||
|
cache:"no-cache",
|
||||||
|
credentials:"same-origin",
|
||||||
|
headers: {
|
||||||
|
"uploadforuser": adduserUsername.value
|
||||||
|
|
||||||
|
},
|
||||||
|
referrerPolicy:"no-referrer",
|
||||||
|
redirect: 'follow',
|
||||||
|
body: image_acc
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
gusInfo.innerHTML = "<p style='color:rgb(130, 255, 163); padding: 1vw;'>Ajout de l'utilisateur <strong>" + adduserUsername.value + "</strong> avec succès.</p>"
|
||||||
|
adduserForm.close()
|
||||||
|
getPage("users.html")
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
addInfo.innerHTML = '<p>' + response.content + '</p>'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
addInfo.innerHTML = '<p">Tous les champs doivent être remplis</p>'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- Style-->
|
<!-- Style-->
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.home {
|
.gus_adduser p {
|
||||||
|
|
||||||
|
margin-top: 0.5vw;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_imagediv {
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
justify-items: center;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.inp {
|
||||||
|
|
||||||
|
border-style: hidden;
|
||||||
|
border-radius: 1vw;
|
||||||
|
padding: 0.2vw;
|
||||||
|
padding-left: 1vw;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_adduser .gus_image_upload {
|
||||||
|
|
||||||
|
margin-top: 1vw;
|
||||||
|
margin-bottom: 1vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
select.inp {
|
||||||
|
|
||||||
|
margin-bottom: 0.5vw;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.inp:hover {
|
||||||
|
|
||||||
|
box-shadow: 2px 2px 5px rgba(255, 255, 255, 0.477) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.inp:focus {
|
||||||
|
|
||||||
|
box-shadow: 5px 5px 5px rgba(0, 174, 255, 0.477) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_adduser {
|
||||||
|
|
||||||
|
border-radius: 1vw;
|
||||||
|
border-color: transparent;
|
||||||
|
background-color: rgb(80, 80, 80);
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_image {
|
||||||
|
|
||||||
|
border-radius: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_close {
|
||||||
|
|
||||||
|
border-radius: 1vw;
|
||||||
|
border-color: rgb(255, 48, 48);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
margin: 0.5vw;
|
||||||
|
padding: 0.5vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_close:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(255, 48, 48);
|
||||||
|
background-color: rgb(255, 48, 48);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_close:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_confirm {
|
||||||
|
|
||||||
|
border-radius: 1vw;
|
||||||
|
border-color: rgb(0, 174, 255);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
margin: 0.5vw;
|
||||||
|
padding: 0.5vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_confirm:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(0, 174, 255);
|
||||||
|
background-color: rgb(0, 174, 255);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add_confirm:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.hbox h1 {
|
.hbox h1 {
|
||||||
@@ -41,6 +663,137 @@ table {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gus_line {
|
||||||
|
|
||||||
|
margin: 1vw;
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
vertical-align: middle;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_image {
|
||||||
|
|
||||||
|
width: 10%;
|
||||||
|
border-radius: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_users {
|
||||||
|
|
||||||
|
margin: 1%;
|
||||||
|
padding: 1%;
|
||||||
|
background-color: rgb(80, 80, 80);
|
||||||
|
border-radius: 1vw;
|
||||||
|
box-shadow: 5px 5px 5px rgba(80, 80, 80, 0.477) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_edit {
|
||||||
|
|
||||||
|
border-radius: 100%;
|
||||||
|
border-color: rgb(0, 174, 255);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
width: 2.5vw;
|
||||||
|
height: 2.5vw;
|
||||||
|
margin-left: 0.5vw;
|
||||||
|
margin-right: 0.5vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_edit:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(0, 174, 255);
|
||||||
|
background-color: rgb(0, 174, 255);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_edit:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_signout {
|
||||||
|
|
||||||
|
border-radius: 100%;
|
||||||
|
border-color: rgb(254, 254, 74);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
width: 2.5vw;
|
||||||
|
height: 2.5vw;
|
||||||
|
margin-left: 0.5vw;
|
||||||
|
margin-right: 0.5vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_signout:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(254, 254, 74);
|
||||||
|
background-color: rgb(254, 254, 74);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_signout:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_delete {
|
||||||
|
|
||||||
|
border-radius: 100%;
|
||||||
|
border-color: rgb(255, 48, 48);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
width: 2.5vw;
|
||||||
|
height: 2.5vw;
|
||||||
|
margin-left: 0.5vw;
|
||||||
|
margin-right: 0.5vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_delete:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(255, 48, 48);
|
||||||
|
background-color: rgb(255, 48, 48);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_delete:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add {
|
||||||
|
|
||||||
|
border-radius: 1vw;
|
||||||
|
border-color: rgb(0, 174, 255);
|
||||||
|
border-width: 1%;
|
||||||
|
border-style: solid;
|
||||||
|
color: white;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
padding: 0.5vw;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add:hover {
|
||||||
|
box-shadow: 1px 1px 10px rgb(0, 174, 255);
|
||||||
|
background-color: rgb(0, 174, 255);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gus_add:active {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.hbox {
|
.hbox {
|
||||||
|
|||||||
+17
-4
@@ -10,7 +10,7 @@ router.get('/', function(req, res, next) {
|
|||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
|
|
||||||
if(check == false) {
|
if(check.name == false) {
|
||||||
|
|
||||||
res.redirect(302, "/login")
|
res.redirect(302, "/login")
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
if(check == false) {
|
if(check.name == false) {
|
||||||
|
|
||||||
res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
|
res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
|
||||||
|
|
||||||
@@ -69,12 +69,25 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
} else if(req.body.request == "username") {
|
} else if(req.body.request == "username") {
|
||||||
|
|
||||||
res.send({"result":"success", "content": ntr.checkToken(req, res)})
|
res.send({"result":"success", "content": ntr.checkToken(req, res).name})
|
||||||
|
|
||||||
|
|
||||||
} else if(req.body.request == "fullname") {
|
} else if(req.body.request == "fullname") {
|
||||||
|
|
||||||
res.send({"result":"success", "content": ntr.getFullName(ntr.checkToken(req, res))})
|
res.send({"result":"success", "content": ntr.getFullName(ntr.checkToken(req, res).name)})
|
||||||
|
|
||||||
|
|
||||||
|
} else if(req.body.request == "all") {
|
||||||
|
|
||||||
|
if(check.permLevel == 4) {
|
||||||
|
res.send({"result":"success", "content": ntr.getAll(req.body.name)})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
res.send({"result":"failed", "content":"ERROR_USER_PERMISSION_TOO_LOW"})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-3
@@ -7,15 +7,15 @@ router.get('/', function(req, res, next) {
|
|||||||
|
|
||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
|
if(check.name == false) {
|
||||||
if(check == false) {
|
|
||||||
|
|
||||||
res.redirect(302, "/login")
|
res.redirect(302, "/login")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
console.log(ntr.getFullName(check.name))
|
||||||
|
|
||||||
res.render('index', { title: ntr.getFullName(check), username: ntr.getFullName(check), accountpic: '<img width="200" class="w-25 sidebar-image noside" src="images/userspics/' + check + '.png">' });
|
res.render('index', { title: ntr.getFullName(check.name), username: ntr.getFullName(check.name), accountpic: '<img width="200" class="w-25 sidebar-image noside" src="images/userspics/' + check.name + '.png">' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ router.get('/', function(req, res, next) {
|
|||||||
|
|
||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
if(check != false) {
|
if(check.name != false) {
|
||||||
|
|
||||||
res.redirect(302, "/")
|
res.redirect(302, "/")
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ router.get('/', function(req, res, next) {
|
|||||||
|
|
||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
if(check != false) {
|
if(check.name != false) {
|
||||||
|
|
||||||
res.redirect(302, "/")
|
res.redirect(302, "/")
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
if(check == false) {
|
if(check.name == false) {
|
||||||
|
|
||||||
res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
|
res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ router.get('/', function(req, res, next) {
|
|||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
|
|
||||||
if(check == false) {
|
if(check.name == false) {
|
||||||
|
|
||||||
res.redirect(302, "/login")
|
res.redirect(302, "/login")
|
||||||
|
|
||||||
|
|||||||
+108
-8
@@ -13,7 +13,7 @@ router.get('/', function(req, res, next) {
|
|||||||
|
|
||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
if(check != false) {
|
if(check.name != false) {
|
||||||
|
|
||||||
res.redirect(302, "/")
|
res.redirect(302, "/")
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
var check = ntr.checkToken(req, res)
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
if(check == false) {
|
if(check.name == false) {
|
||||||
|
|
||||||
res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
|
res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
|
||||||
|
|
||||||
@@ -37,6 +37,10 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
const image = req.files.apic
|
const image = req.files.apic
|
||||||
|
|
||||||
|
if(req.headers.uploadforuser != null) {
|
||||||
|
|
||||||
|
if(check.permLevel == 4) {
|
||||||
|
|
||||||
if(req.files.apic.mimetype == "image/png" | req.files.apic.mimetype == "image/jpeg" ) {
|
if(req.files.apic.mimetype == "image/png" | req.files.apic.mimetype == "image/jpeg" ) {
|
||||||
|
|
||||||
var uploadPath = "";
|
var uploadPath = "";
|
||||||
@@ -44,12 +48,12 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
if(req.files.apic.mimetype == "image/png") {
|
if(req.files.apic.mimetype == "image/png") {
|
||||||
|
|
||||||
uploadPath = ntr.checkToken(req, res) + ".png"
|
uploadPath = req.headers.uploadforuser + ".png"
|
||||||
}
|
}
|
||||||
|
|
||||||
if(req.files.apic.mimetype == "image/jpeg") {
|
if(req.files.apic.mimetype == "image/jpeg") {
|
||||||
|
|
||||||
uploadPath = ntr.checkToken(req, res) + ".jpg"
|
uploadPath = req.headers.uploadforuser+ ".jpg"
|
||||||
}
|
}
|
||||||
|
|
||||||
image.mv(uploadPath, function(err) {
|
image.mv(uploadPath, function(err) {
|
||||||
@@ -60,11 +64,11 @@ router.post("/", function(req, res, next) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(fs.existsSync(uploadDir + ntr.checkToken(req, res) + ".png") | fs.existsSync(uploadDir + ntr.checkToken(req, res) + ".jpg")) {
|
if(fs.existsSync(uploadDir + req.headers.uploadforuser + ".png") | fs.existsSync(uploadDir + req.headers.uploadforuser + ".jpg")) {
|
||||||
|
|
||||||
if(fs.existsSync(uploadDir + ntr.checkToken(req, res) + ".png")) {
|
if(fs.existsSync(uploadDir + req.headers.uploadforuser+ ".png")) {
|
||||||
|
|
||||||
fs.rmSync(uploadDir + ntr.checkToken(req, res) + ".png")
|
fs.rmSync(uploadDir + req.headers.uploadforuser + ".png")
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.renameSync(__dirname.replace("routes", "") + uploadPath , uploadDir + uploadPath)
|
fs.renameSync(__dirname.replace("routes", "") + uploadPath , uploadDir + uploadPath)
|
||||||
@@ -74,7 +78,102 @@ router.post("/", function(req, res, next) {
|
|||||||
image.resize(200,200, function(err){
|
image.resize(200,200, function(err){
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
}).write(uploadDir + uploadPath.replace("jpg", "png"))
|
}).write(uploadDir + uploadPath.replace("jpg", "png"))
|
||||||
fs.rmSync(uploadDir + ntr.checkToken(req, res) + ".jpg")
|
fs.rmSync(uploadDir + req.headers.uploadforuser + ".jpg")
|
||||||
|
|
||||||
|
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if(req.files.apic.mimetype == "image/png") {
|
||||||
|
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
||||||
|
image.resize(200,200, function(err){
|
||||||
|
if (err) throw err;
|
||||||
|
}).write(uploadDir + uploadPath)
|
||||||
|
|
||||||
|
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
console.log(uploadDir + uploadPath)
|
||||||
|
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
|
||||||
|
console.log("ERROR - UPLOAD NOT WORK CORRECYLT")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
res.send({"result":"success", "content": "Seul les images (JPEG et PNG) sont acceptés."})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
if(req.files.apic.mimetype == "image/png" | req.files.apic.mimetype == "image/jpeg" ) {
|
||||||
|
|
||||||
|
var uploadPath = "";
|
||||||
|
var uploadDir = __dirname.replace("routes","public" + path.sep + "images" + path.sep + "userspics" + path.sep)
|
||||||
|
|
||||||
|
if(req.files.apic.mimetype == "image/png") {
|
||||||
|
|
||||||
|
uploadPath = ntr.checkToken(req, res).name + ".png"
|
||||||
|
}
|
||||||
|
|
||||||
|
if(req.files.apic.mimetype == "image/jpeg") {
|
||||||
|
|
||||||
|
uploadPath = ntr.checkToken(req, res).name + ".jpg"
|
||||||
|
}
|
||||||
|
|
||||||
|
image.mv(uploadPath, function(err) {
|
||||||
|
if(err) {
|
||||||
|
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
|
||||||
|
console.log(err)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(fs.existsSync(uploadDir + ntr.checkToken(req, res).name + ".png") | fs.existsSync(uploadDir + ntr.checkToken(req, res).name + ".jpg")) {
|
||||||
|
|
||||||
|
if(fs.existsSync(uploadDir + ntr.checkToken(req, res).name + ".png")) {
|
||||||
|
|
||||||
|
fs.rmSync(uploadDir + ntr.checkToken(req, res).name + ".png")
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.renameSync(__dirname.replace("routes", "") + uploadPath , uploadDir + uploadPath)
|
||||||
|
|
||||||
|
if(req.files.apic.mimetype == "image/jpeg") {
|
||||||
|
Jimp.read(uploadDir + uploadPath, function (err, image) {
|
||||||
|
image.resize(200,200, function(err){
|
||||||
|
if (err) throw err;
|
||||||
|
}).write(uploadDir + uploadPath.replace("jpg", "png"))
|
||||||
|
fs.rmSync(uploadDir + ntr.checkToken(req, res).name + ".jpg")
|
||||||
|
|
||||||
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
res.send({"result":"success", "content": "<span style='color:rgb(130, 255, 163);'>La photo de profil a été changé avec succès.</span>",})
|
||||||
|
|
||||||
@@ -128,6 +227,7 @@ router.post("/", function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var router = express.Router();
|
||||||
|
var ntr = require("../neutral-functions.js")
|
||||||
|
|
||||||
|
/* GET home page. */
|
||||||
|
router.get('/', function(req, res, next) {
|
||||||
|
|
||||||
|
|
||||||
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
|
if(check.name != false) {
|
||||||
|
|
||||||
|
res.redirect(302, "/")
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.render('login', {error: ""});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post("/", function(req, res, next) {
|
||||||
|
|
||||||
|
var check = ntr.checkToken(req, res)
|
||||||
|
|
||||||
|
if(check.name == false) {
|
||||||
|
|
||||||
|
res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(check.permLevel == 4) {
|
||||||
|
|
||||||
|
const bod = req.body
|
||||||
|
|
||||||
|
if(bod.request == "add") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var level = 1;
|
||||||
|
|
||||||
|
if(bod.value.permLevel == 'Niveau 1 : (Utilisateur)') {
|
||||||
|
level = 1
|
||||||
|
|
||||||
|
} else if(bod.value.permLevel == 'Niveau 2 : (Editeur)') {
|
||||||
|
level = 2
|
||||||
|
|
||||||
|
} else if(bod.value.permLevel == 'Niveau 3 : (Operateur)') {
|
||||||
|
level = 3
|
||||||
|
|
||||||
|
} else if(bod.value.permLevel == 'Niveau 4 : (Administrateur)') {
|
||||||
|
level = 4
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const resp = ntr.createUser(bod.value.username, bod.value.password, level, bod.value.fullname)
|
||||||
|
|
||||||
|
if(resp == "USER_ALREADY_EXIST") {
|
||||||
|
|
||||||
|
res.send({"result":"success", "content":"L'utilisateur existe déjà."})
|
||||||
|
|
||||||
|
|
||||||
|
} else if(resp == 'USER_CREATED') {
|
||||||
|
|
||||||
|
res.send({"result":"success", "content":"VALID"})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"failed", "content":"ERROR_USER_NOT_WORK", "additional": "REQUEST_MISSING"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if(bod.request == "get") {
|
||||||
|
|
||||||
|
|
||||||
|
var users = []
|
||||||
|
|
||||||
|
for(var element of ntr.getUsers().keys()) {
|
||||||
|
|
||||||
|
users.push(element)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
res.send({"result": "success", "content": users})
|
||||||
|
|
||||||
|
} else if(bod.request == "del") {
|
||||||
|
|
||||||
|
const resp = ntr.deleteUser(bod.value)
|
||||||
|
|
||||||
|
if(resp == "USER_ALREADY_DELETED") {
|
||||||
|
|
||||||
|
res.send({"result":"success", "content":"L'utilisateur n'existe déjà plus."})
|
||||||
|
|
||||||
|
|
||||||
|
} else if(resp == 'USER_DELETED') {
|
||||||
|
|
||||||
|
res.send({"result":"success", "content":"VALID"})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"failed", "content":"ERROR_USER_NOT_WORK", "additional": "REQUEST_MISSING"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if(bod.request == "deco") {
|
||||||
|
|
||||||
|
ntr.deleteToken(bod.value)
|
||||||
|
res.send({"result":"success", "content":"VALID"})
|
||||||
|
} else if(bod.request == "edit") {
|
||||||
|
|
||||||
|
const resp = ntr.editUser(bod.value)
|
||||||
|
|
||||||
|
if(resp == true) {
|
||||||
|
res.send({"result":"success","content":"DATA_VALID"})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"success","content":"EDIT_USER_FAILED"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
|
res.send({"result":"failed", "content":"ERROR_REQUEST_MISSING_FIELDS", "additional": "REQUEST_MISSING"})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
res.send({"result":"failed", "content":"ERROR_USER_PERMISSION_TOO_LOW"})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
+3
-4
@@ -1,11 +1,10 @@
|
|||||||
// Import our custom CSS
|
// Import our custom CSS
|
||||||
import '../scss/styles.scss'
|
|
||||||
import '@fortawesome/fontawesome-free/css/all.css'
|
import '@fortawesome/fontawesome-free/css/all.css'
|
||||||
|
import '../scss/styles.scss'
|
||||||
// Import all of Bootstrap's JS
|
// Import all of Bootstrap's JS
|
||||||
import * as bootstrap from 'bootstrap'
|
import * as bootstrap from 'bootstrap'
|
||||||
import * as jquery from 'jquery'
|
import JQuery from 'jquery';
|
||||||
|
|
||||||
|
|
||||||
|
window.$ = window.JQuery = JQuery;
|
||||||
|
|
||||||
console.log("Webpack Loaded");
|
console.log("Webpack Loaded");
|
||||||
File renamed without changes.
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"username": "root",
|
|
||||||
"password": "U2FsdGVkX183RDwFR0hVxkFizv9rTwppNiaWkUVowis=",
|
|
||||||
"uuid": "24a17fe1-32c3-4269-b83b-88b6bcd66cef",
|
|
||||||
"fullname": "Admin",
|
|
||||||
"token": {
|
|
||||||
"tokenID": "5aefa3fc-1e35-4195-89ab-b1603e867a51",
|
|
||||||
"livableToken": true,
|
|
||||||
"createdAt": 1676914169253
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"username": "raphix",
|
"username": "raphix",
|
||||||
"password": "U2FsdGVkX195kOSeYbWRWFD3ys/5ubkaNSm9XacK0OE=",
|
"password": "U2FsdGVkX1+y5WFBRAA0GITGyxl0AOq2lygx7XDu6BU=",
|
||||||
"uuid": "9ace80e0-1ee3-4eed-924f-8a55fc55822b",
|
"uuid": "9ace80e0-1ee3-4eed-924f-8a55fc55822b",
|
||||||
|
"permissionLevel": 4,
|
||||||
"fullname": "Raphael PICOT",
|
"fullname": "Raphael PICOT",
|
||||||
"token": {
|
"token": {
|
||||||
"tokenID": "1679485c-2139-4939-a429-56480bba0336",
|
"tokenID": "43b6f1bf-29be-4801-83f2-b1e85dcb3981",
|
||||||
"livableToken": true,
|
"livableToken": true,
|
||||||
"createdAt": 1676925451610
|
"createdAt": 1677070566103
|
||||||
}
|
},
|
||||||
|
"lastconnexion": 1677070621299
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"username": "root",
|
||||||
|
"password": "U2FsdGVkX18KoGGTPqZw/E9PiLQaUuEZxyHdbdAErO0=",
|
||||||
|
"uuid": "aca3c9aa-5b42-477f-b179-f33211a425d3",
|
||||||
|
"fullname": "Administrateur",
|
||||||
|
"permissionLevel": 3,
|
||||||
|
"token": {},
|
||||||
|
"lastconnexion": 0
|
||||||
|
}
|
||||||
Reference in new issue
Block a user