Version 0.2.0 - PREVERSION - Ajout de certaines fonctionnalités
All checks were successful
Neutral/pipeline/head This commit looks good

This commit is contained in:
Raphix
2023-11-02 18:16:15 +01:00
parent a3e0f25968
commit 9c1074de80
17 changed files with 888 additions and 18 deletions

View File

@ -45,11 +45,40 @@ module.exports.fetchUsers = function () {
permission: userFetched.permission,
tokens: userFetched.tokens,
lastLogin: userFetched.lastLogin,
picture: userFetched.picture
})
usersList.set(user.username, user)
}
if(usersList.size == 0) {
const adminUser = new this.User({
"username": "admin",
"password": "neutral",
"display_name": "Administrateur",
"permission": [
"FILES_EXPLORER",
"SERVICES",
"SERVERS",
"PIPELINES",
"METRICS",
"USERS",
"LINKS",
"SETTINGS"
],
"tokens": [],
"lastLogin": "DEFAULT ACCOUNT",
"picture": "/images/users/default.jpg"
})
adminUser.register()
}
ulog.step.end("fetch_user")
}
@ -64,7 +93,7 @@ module.exports.User = class {
permission = []
tokens = []
lastLogin = new Date()
picture = "/images/users/default.jpg"
constructor(properties) {
@ -76,6 +105,7 @@ module.exports.User = class {
this.permission = properties.permission
this.tokens = properties.tokens
this.lastLogin = properties.lastLogin
this.picture = properties.picture
const userFile = getFile()
@ -123,7 +153,9 @@ module.exports.User = class {
if(this.lastLogin == null) {
this.lastLogin = new Date()
}
if(this.picture == null) {
this.picture = "/images/users/default.jpg"
}
}
@ -251,6 +283,28 @@ module.exports.User = class {
}
setPicture(text) {
this.#sync()
this.picture = text
this.register()
ulog.log("La photo de l'utilisateur a été modifié : " + this.username)
}
setDisplayName(text) {
this.#sync()
this.display_name = text
this.register()
ulog.log("Le nom d'affichage de l'utilisateur a été modifié : " + this.username)
}
setLastLogin(text) {
this.#sync()
this.lastLogin = text
this.register()
}
#sync() {
for(var userGet of usersList.keys()) {