commit
22f17d88f2
28 changed files with 61 additions and 54 deletions
|
@ -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_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_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_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 reg_classe = /(?:(LP)[ -]{0,}(.*)|(?:(G[0-9])(S[0-9])))/;
|
||||||
const base_url = config["edt"];
|
const base_url = config["edt"];
|
||||||
|
@ -82,8 +83,14 @@ function fetchEvents(days = 1, TS_Start = new Date()) {
|
||||||
/*
|
/*
|
||||||
Teachers
|
Teachers
|
||||||
*/
|
*/
|
||||||
event["teachers"] = m[6].split("\\n");
|
event['teachers'] = []
|
||||||
event["teachers"].pop();
|
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);
|
output.push(event);
|
||||||
}
|
}
|
||||||
resolve(output);
|
resolve(output);
|
||||||
|
|
4
app.js
4
app.js
|
@ -12,8 +12,8 @@ const edtRouter = require("./routes/edt");
|
||||||
const homeRouter = require("./routes/home");
|
const homeRouter = require("./routes/home");
|
||||||
const marksRouter = require("./routes/marks");
|
const marksRouter = require("./routes/marks");
|
||||||
const registerRouter = require("./routes/register");
|
const registerRouter = require("./routes/register");
|
||||||
const viescolRouter = require("./routes/viescol")
|
const viescolRouter = require("./routes/viescol");
|
||||||
const profilRouter = require("./routes/profil")
|
const profilRouter = require("./routes/profil");
|
||||||
|
|
||||||
let app = express();
|
let app = express();
|
||||||
const sessionMiddleware = session({
|
const sessionMiddleware = session({
|
||||||
|
|
12
bin/www
12
bin/www
|
@ -30,7 +30,7 @@ fs.writeFileSync("public/stylesheets/style.css", css.css);
|
||||||
* Get port from environment and store in Express.
|
* 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("port", port);
|
||||||
app.set("mailClient", mailClient);
|
app.set("mailClient", mailClient);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ app.set("mailClient", mailClient);
|
||||||
* Create HTTP server.
|
* Create HTTP server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create socket.io server
|
* Create socket.io server
|
||||||
|
@ -66,7 +66,7 @@ models.sequelize.sync().then(() => {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function normalizePort(val) {
|
function normalizePort(val) {
|
||||||
let port = parseInt(val, 10);
|
const port = parseInt(val, 10);
|
||||||
|
|
||||||
if (isNaN(port)) {
|
if (isNaN(port)) {
|
||||||
// named pipe
|
// named pipe
|
||||||
|
@ -90,7 +90,7 @@ function onError(error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bind = typeof port === "string"
|
const bind = typeof port === "string"
|
||||||
? "Pipe " + port
|
? "Pipe " + port
|
||||||
: "Port " + port;
|
: "Port " + port;
|
||||||
|
|
||||||
|
@ -114,8 +114,8 @@ function onError(error) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onListening() {
|
function onListening() {
|
||||||
let addr = server.address();
|
const addr = server.address();
|
||||||
let bind = typeof addr === "string"
|
const bind = typeof addr === "string"
|
||||||
? "pipe " + addr
|
? "pipe " + addr
|
||||||
: "port " + addr.port;
|
: "port " + addr.port;
|
||||||
debug("Listening on " + bind);
|
debug("Listening on " + bind);
|
||||||
|
|
|
@ -8,7 +8,7 @@ const {
|
||||||
} = require("sequelize");
|
} = require("sequelize");
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
function hash(password, email) {
|
function hash(password, email) {
|
||||||
let cipher = crypto.createCipheriv(
|
const cipher = crypto.createCipheriv(
|
||||||
"aes-256-cbc",
|
"aes-256-cbc",
|
||||||
privateKey,
|
privateKey,
|
||||||
crypto.createHash("md5").update(email).digest("base64").slice(0, 16)
|
crypto.createHash("md5").update(email).digest("base64").slice(0, 16)
|
||||||
|
@ -19,7 +19,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||||
class User extends Model {
|
class User extends Model {
|
||||||
static associate(models) {
|
static associate(models) {
|
||||||
User.belongsToMany(models.Group, {through: "UserGroup"});
|
User.belongsToMany(models.Group, {through: "UserGroup"});
|
||||||
User.belongsToMany(models.Event, {through: "EventTeacher"})
|
User.belongsToMany(models.Event, {through: "EventTeacher"});
|
||||||
User.belongsToMany(models.UE, {through: "UEUser"});
|
User.belongsToMany(models.UE, {through: "UEUser"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ document.getElementById("login").addEventListener("submit", e=>{
|
||||||
alert('Format d\'email incorrect.');
|
alert('Format d\'email incorrect.');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
});
|
||||||
|
|
||||||
socket.on("login", data=>{
|
socket.on("login", data=>{
|
||||||
if(data.error){
|
if(data.error){
|
||||||
|
@ -19,4 +19,4 @@ socket.on("login", data=>{
|
||||||
}else{
|
}else{
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
}
|
}
|
||||||
})
|
});
|
|
@ -18,7 +18,7 @@ socket.on("logout", data=>{
|
||||||
}else{
|
}else{
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
function profilRedirect(){
|
function profilRedirect(){
|
||||||
|
|
|
@ -18,4 +18,4 @@ socket.on("profileEdit", data=>{
|
||||||
}else{
|
}else{
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
}
|
}
|
||||||
})
|
});
|
|
@ -20,4 +20,4 @@ socket.on("register", data=>{
|
||||||
}else{
|
}else{
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
res.render("pages/edt", { title: "L'ETU" });
|
res.render("pages/edt", { title: "L'ETU" });
|
||||||
|
|
|
@ -8,7 +8,7 @@ const sessionCheck = require("./utils/sessionCheck");
|
||||||
router.get("/check", async (req, res) => {
|
router.get("/check", async (req, res) => {
|
||||||
if (!req.query.token)
|
if (!req.query.token)
|
||||||
return error(req, res, "Missing argument", 400);
|
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) {
|
if (user) {
|
||||||
user.emailVerified = true;
|
user.emailVerified = true;
|
||||||
if (user.email.endsWith("@etu.univ-lyon1.fr"))
|
if (user.email.endsWith("@etu.univ-lyon1.fr"))
|
||||||
|
@ -25,7 +25,7 @@ router.get("/forget", sessionCheck(-1), async (req, res) => {
|
||||||
if (!req.query.token)
|
if (!req.query.token)
|
||||||
res.render("forget", {title: "L'ETU"});
|
res.render("forget", {title: "L'ETU"});
|
||||||
else {
|
else {
|
||||||
let user = await models.User.findOne({where: {passwordToken: data.token}});
|
const user = await models.User.findOne({where: {passwordToken: data.token}});
|
||||||
if (!user)
|
if (!user)
|
||||||
return error(req, res, "Invalid token", 400);
|
return error(req, res, "Invalid token", 400);
|
||||||
else if (user.passwordTokenDate && ((new Date().getTime() - user.passwordTokenDate.getTime()) / 1000 > 3600))
|
else if (user.passwordTokenDate && ((new Date().getTime() - user.passwordTokenDate.getTime()) / 1000 > 3600))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
const sessionCheck = require("./utils/sessionCheck");
|
const sessionCheck = require("./utils/sessionCheck");
|
||||||
|
|
||||||
router.get("/", sessionCheck(1), (req, res) => {
|
router.get("/", sessionCheck(1), (req, res) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
const sessionCheck = require("./utils/sessionCheck");
|
const sessionCheck = require("./utils/sessionCheck");
|
||||||
|
|
||||||
router.get("/",sessionCheck(-1), (req, res) => {
|
router.get("/",sessionCheck(-1), (req, res) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
res.render("pages/marks", { title: "L'ETU" });
|
res.render("pages/marks", { title: "L'ETU" });
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
res.render("pages/profil", { title: "L'ETU" });
|
res.render("pages/profil", { title: "L'ETU" });
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
const sessionCheck = require("./utils/sessionCheck");
|
const sessionCheck = require("./utils/sessionCheck");
|
||||||
|
|
||||||
router.get("/",sessionCheck(-1), (req, res) => {
|
router.get("/",sessionCheck(-1), (req, res) => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
let error = require("./error");
|
const error = require("./error");
|
||||||
|
|
||||||
function sessionCheck(permission) {
|
function sessionCheck(permission) {
|
||||||
return (req, res, next) => {
|
return (req, res, next) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let express = require("express");
|
const express = require("express");
|
||||||
let router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
res.render("pages/viescol", { title: "L'ETU" });
|
res.render("pages/viescol", { title: "L'ETU" });
|
||||||
|
|
|
@ -11,4 +11,4 @@ module.exports = socket => {
|
||||||
else
|
else
|
||||||
await emailCheck(socket, user, null);
|
await emailCheck(socket, user, null);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -10,4 +10,4 @@ module.exports = socket => {
|
||||||
else
|
else
|
||||||
await emailPassword(socket, user, null);
|
await emailPassword(socket, user, null);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = socket => {
|
||||||
return async (data) => {
|
return async (data) => {
|
||||||
let user = await models.User.findOne({where: {passwordToken: data.token}});
|
let user = await models.User.findOne({where: {passwordToken: data.token}});
|
||||||
if (!user)
|
if (!user)
|
||||||
socket.emit("setPassword", {error: {message: "invalid_token"}})
|
socket.emit("setPassword", {error: {message: "invalid_token"}});
|
||||||
else if (user.passwordTokenDate && ((new Date().getTime() - user.passwordTokenDate.getTime()) / 1000 > 3600))
|
else if (user.passwordTokenDate && ((new Date().getTime() - user.passwordTokenDate.getTime()) / 1000 > 3600))
|
||||||
socket.emit("setPassword", {error: {message: "expired_token"}});
|
socket.emit("setPassword", {error: {message: "expired_token"}});
|
||||||
else {
|
else {
|
||||||
|
@ -16,4 +16,4 @@ module.exports = socket => {
|
||||||
socket.emit("setPassword", true);
|
socket.emit("setPassword", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -15,4 +15,4 @@ module.exports = socket => {
|
||||||
socket.emit("login", user)
|
socket.emit("login", user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -7,4 +7,4 @@ module.exports = socket => {
|
||||||
socket.emit("logout", {error: { message: "not_logged_in"}});
|
socket.emit("logout", {error: { message: "not_logged_in"}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
|
@ -6,7 +6,7 @@ module.exports = socket => {
|
||||||
if (!user)
|
if (!user)
|
||||||
socket.emit("profileEdit", {error: {message: "not_found"}});
|
socket.emit("profileEdit", {error: {message: "not_found"}});
|
||||||
else if (!user.checkPassword(data.oldPassword))
|
else if (!user.checkPassword(data.oldPassword))
|
||||||
socket.emit("profileEdit", {error: {message: "invalid_password"}})
|
socket.emit("profileEdit", {error: {message: "invalid_password"}});
|
||||||
else {
|
else {
|
||||||
if (data.firstName !== user.firstName)
|
if (data.firstName !== user.firstName)
|
||||||
user.firstName = data.firstName;
|
user.firstName = data.firstName;
|
||||||
|
@ -14,10 +14,10 @@ module.exports = socket => {
|
||||||
user.lastName = data.lastName;
|
user.lastName = data.lastName;
|
||||||
user.newPassword = data.newPassword;
|
user.newPassword = data.newPassword;
|
||||||
if (data.password && !user.checkPassword(data.password))
|
if (data.password && !user.checkPassword(data.password))
|
||||||
user.passwordHash = data.password
|
user.passwordHash = data.password;
|
||||||
socket.request.session.user = user;
|
socket.request.session.user = user;
|
||||||
socket.request.session.save();
|
socket.request.session.save();
|
||||||
socket.emit("profileEdit", user)
|
socket.emit("profileEdit", user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -18,4 +18,4 @@ module.exports = socket => {
|
||||||
await emailCheck(socket, user, null);
|
await emailCheck(socket, user, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
|
@ -16,7 +16,7 @@ module.exports = async (socket, user, callBack) => {
|
||||||
subject: "forgot password"
|
subject: "forgot password"
|
||||||
}), async (err, message) => {
|
}), async (err, message) => {
|
||||||
if (err)
|
if (err)
|
||||||
socket.emit("forgotPassword", {error: {message: "fail_send_mail"}})
|
socket.emit("forgotPassword", {error: {message: "fail_send_mail"}});
|
||||||
else {
|
else {
|
||||||
user.passwordToken = token;
|
user.passwordToken = token;
|
||||||
user.passwordTokenDate = new Date();
|
user.passwordTokenDate = new Date();
|
||||||
|
|
|
@ -20,7 +20,7 @@ async function clean() {
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
[app, models] = await setup();
|
[app, models] = await setup();
|
||||||
})
|
});
|
||||||
|
|
||||||
it("Main page content", async () => {
|
it("Main page content", async () => {
|
||||||
await request(app)
|
await request(app)
|
||||||
|
|
|
@ -7,9 +7,9 @@ html
|
||||||
link(rel="stylesheet", href="/stylesheets/style.css")
|
link(rel="stylesheet", href="/stylesheets/style.css")
|
||||||
script(src="/socket.io/socket.io.js")
|
script(src="/socket.io/socket.io.js")
|
||||||
body
|
body
|
||||||
- var student = false
|
- let student = false
|
||||||
- var teacher = true
|
- let teacher = true
|
||||||
- var admin = false
|
- let admin = false
|
||||||
div(class="row" id="page")
|
div(class="row" id="page")
|
||||||
div(class="col s2" id="panel")
|
div(class="col s2" id="panel")
|
||||||
block navbar
|
block navbar
|
||||||
|
|
Reference in a new issue