1
0
Fork 0

Fix const vars

This commit is contained in:
Ethanell 2020-12-12 18:28:44 +01:00
parent fdfbcceb01
commit e6470383c3
13 changed files with 38 additions and 31 deletions

View file

@ -4,6 +4,7 @@ const models = require("../models");
const reg_event = /(?:(?:BEGIN:VEVENT\nDTSTAMP:(?:[A-Z0-9]*?)\nDTSTART:([A-Z0-9]*?)\nDTEND:([A-Z0-9]*?)\nSUMMARY: {0,}([a-zéèàA-Z0-9-. \, \\/ô]*?)\nLOCATION:([a-zA-Zéèà0-9-. \,\\]*?)\nDESCRIPTION:(?:\\n){0,}(LP(?:[ a-zA-Z0-9]*))\\n((?:(?:[A-Z]*) (?:[A-Z]*)(?: (?:[A-Z]*)){0,}\\n){0,})(?:.*?)\nEND:VEVENT)|(?:BEGIN:VEVENT\nDTSTAMP:(?:[A-Z0-9]*?)\nDTSTART:([A-Z0-9]*?)\nDTEND:([A-Z0-9]*?)\nSUMMARY: {0,}((?:S(?:[A-Z0-9-]*)|M(?:[A-Z0-9-]*)(?:\/M(?:[A-Z0-9-]*)){0,}|Conférence)[a-zéèàA-Z0-9-. \, \\/]*?)\nLOCATION:([a-zA-Zéèà0-9-. \,\\]*?)\nDESCRIPTION:(?:\\n){0,}((?:(?:G[0-9]S[0-9]|S[0-9]|ASPE)\\n){0,})((?:(?:[A-Z]*) (?:[A-Z]*)(?: (?:[A-Z]*)){0,}\\n){0,})(?:.*?)\nEND:VEVENT))/gs;
const reg_location = /((?:[SH0-9][0-9]{2})|(?:(?:Préfa |Amphi)[0-9]))/g;
const reg_teachers = /^(?:((?:[a-zA-Z]*[ -]{0,}){0,}) ([a-zA-Z]*))$/m;
const reg_date = /([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z/;
const reg_classe = /(?:(LP)[ -]{0,}(.*)|(?:(G[0-9])(S[0-9])))/;
const base_url = config["edt"];
@ -82,8 +83,14 @@ function fetchEvents(days = 1, TS_Start = new Date()) {
/*
Teachers
*/
event["teachers"] = m[6].split("\\n");
event["teachers"].pop();
event['teachers'] = []
let fullTeachers = m[6].split('\\n');
fullTeachers.forEach(e => {
if(e !== ""){
let splittedTeachers = reg_teachers.exec(e);
event['teachers'].push([splittedTeachers[1],splittedTeachers[2]]);
}
});
output.push(event);
}
resolve(output);

12
bin/www
View file

@ -30,7 +30,7 @@ fs.writeFileSync("public/stylesheets/style.css", css.css);
* Get port from environment and store in Express.
*/
let port = normalizePort(process.env.PORT || "3000");
const port = normalizePort(process.env.PORT || "3000");
app.set("port", port);
app.set("mailClient", mailClient);
@ -38,7 +38,7 @@ app.set("mailClient", mailClient);
* Create HTTP server.
*/
let server = http.createServer(app);
const server = http.createServer(app);
/**
* Create socket.io server
@ -66,7 +66,7 @@ models.sequelize.sync().then(() => {
*/
function normalizePort(val) {
let port = parseInt(val, 10);
const port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
@ -90,7 +90,7 @@ function onError(error) {
throw error;
}
let bind = typeof port === "string"
const bind = typeof port === "string"
? "Pipe " + port
: "Port " + port;
@ -114,8 +114,8 @@ function onError(error) {
*/
function onListening() {
let addr = server.address();
let bind = typeof addr === "string"
const addr = server.address();
const bind = typeof addr === "string"
? "pipe " + addr
: "port " + addr.port;
debug("Listening on " + bind);

View file

@ -8,7 +8,7 @@ const {
} = require("sequelize");
module.exports = (sequelize, DataTypes) => {
function hash(password, email) {
let cipher = crypto.createCipheriv(
const cipher = crypto.createCipheriv(
"aes-256-cbc",
privateKey,
crypto.createHash("md5").update(email).digest("base64").slice(0, 16)

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
router.get("/", (req, res) => {
res.render("pages/edt", { title: "L'ETU" });

View file

@ -8,7 +8,7 @@ const sessionCheck = require("./utils/sessionCheck");
router.get("/check", async (req, res) => {
if (!req.query.token)
return error(req, res, "Missing argument", 400);
let user = await models.User.findOne({where: {emailToken: req.query.token}});
const user = await models.User.findOne({where: {emailToken: req.query.token}});
if (user) {
user.emailVerified = true;
if (user.email.endsWith("@etu.univ-lyon1.fr"))
@ -25,7 +25,7 @@ router.get("/forget", sessionCheck(-1), async (req, res) => {
if (!req.query.token)
res.render("forget", {title: "L'ETU"});
else {
let user = await models.User.findOne({where: {passwordToken: data.token}});
const user = await models.User.findOne({where: {passwordToken: data.token}});
if (!user)
return error(req, res, "Invalid token", 400);
else if (user.passwordTokenDate && ((new Date().getTime() - user.passwordTokenDate.getTime()) / 1000 > 3600))

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
/* GET home page. */
router.get("/", (req, res) => {

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
const sessionCheck = require("./utils/sessionCheck");
router.get("/", sessionCheck(1), (req, res) => {

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
const sessionCheck = require("./utils/sessionCheck");
router.get("/",sessionCheck(-1), (req, res) => {

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
router.get("/", (req, res) => {
res.render("pages/marks", { title: "L'ETU" });

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
router.get("/", (req, res) => {
res.render("pages/profil", { title: "L'ETU" });

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
const sessionCheck = require("./utils/sessionCheck");
router.get("/",sessionCheck(-1), (req, res) => {

View file

@ -1,4 +1,4 @@
let error = require("./error");
const error = require("./error");
function sessionCheck(permission) {
return (req, res, next) => {

View file

@ -1,5 +1,5 @@
let express = require("express");
let router = express.Router();
const express = require("express");
const router = express.Router();
router.get("/", (req, res) => {
res.render("pages/viescol", { title: "L'ETU" });