Commit d39d0941 authored by Romain OZDEN's avatar Romain OZDEN

Formulaire d'ajout d'un utilisateur

parent f808a8b5
(function dbInit() {
const alasql = require('alasql');
alasql(`
CREATE FILESTORAGE DATABASE IF NOT EXISTS annales("${__dirname}/db.json");
ATTACH FILESTORAGE DATABASE annales("${__dirname}/db.json");
USE annales;
SOURCE "${__dirname}/init.sql";
`);
}());
\ No newline at end of file
CREATE TABLE IF NOT EXISTS Promo (
promo_id number UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
annee string,
specialite string
);
CREATE TABLE IF NOT EXISTS `Role` (
role_id number UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
nom string
);
CREATE TABLE IF NOT EXISTS Utilisateur (
`user_id` number UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
identifiant string NOT NULL UNIQUE,
mot_de_passe string NOT NULL,
nom string,
prenom string,
email string,
role_id number UNSIGNED NOT NULL,
CONSTRAINT `fk_user_role` FOREIGN KEY (role_id) REFERENCES Role (role_id)
);
CREATE TABLE IF NOT EXISTS Matiere (
matiere_id number UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
nom string,
`user_id` number UNSIGNED NOT NULL,
promo_id number UNSIGNED NOT NULL,
CONSTRAINT `fj_mat_user` FOREIGN KEY (`user_id`) REFERENCES Utilisateur (`user_id`),
CONSTRAINT `fk_mat_promo` FOREIGN KEY (promo_id) REFERENCES Promo (promo_id)
);
CREATE TABLE IF NOT EXISTS Sujet (
sujet_id number UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
nom string,
pdf_sujet string,
pdf_correction string,
verif boolean,
date_depot date,
matiere_id number UNSIGNED NOT NULL,
CONSTRAINT `fk_suj_mat` FOREIGN KEY (matiere_id) REFERENCES Matiere (matiere_id)
);
CREATE TABLE IF NOT EXISTS Commentaire (
com_id number UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
position number UNSIGNED,
`message` string,
typesujet string,
sujet_id number UNSIGNED NOT NULL,
`user_id` number UNSIGNED NOT NULL,
CONSTRAINT `fk_com_suj` FOREIGN KEY (sujet_id) REFERENCES Sujet (sujet_id),
CONSTRAINT `fk_com_user` FOREIGN KEY (`user_id`) REFERENCES Utilisateur (`user_id`)
);
CREATE TABLE IF NOT EXISTS `Notification` (
notif_id number UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` number UNSIGNED NOT NULL,
CONSTRAINT `fk_notif_user` FOREIGN KEY (`user_id`) REFERENCES Utilisateur (`user_id`)
);
CREATE TABLE IF NOT EXISTS `Suivre` (
matiere_id number UNSIGNED NOT NULL,
`user_id` number UNSIGNED NOT NULL,
PRIMARY KEY (matiere_id, `user_id`),
CONSTRAINT `fk_suj_mat` FOREIGN KEY (matiere_id) REFERENCES Matiere (matiere_id),
CONSTRAINT `fk_notif_user` FOREIGN KEY (`user_id`) REFERENCES Utilisateur (`user_id`)
);
\ No newline at end of file
This diff is collapsed.
......@@ -5,7 +5,8 @@
"main": "serveur.js",
"scripts": {
"test": "node ./node_modules/gulp/bin/gulp.js",
"start": "node ./node_modules/nodemon/bin/nodemon.js --exec node serveur.js"
"start": "node ./node_modules/nodemon/bin/nodemon.js --exec node serveur.js",
"dbinit": "node ./db/dbInit.js"
},
"repository": {
"type": "git",
......@@ -18,11 +19,13 @@
"license": "ISC",
"dependencies": {
"alasql": "^0.6.1",
"bcrypt": "^4.0.1",
"express": "^4.17.1",
"gulp": "^4.0.1",
"gulp-cached": "^1.1.1",
"gulp-eslint": "^6.0.0",
"gulp-watch": "^5.0.1",
"jsonwebtoken": "^8.5.1",
"nodemon": "^2.0.4"
}
}
......@@ -6,7 +6,7 @@
<meta charset="utf-8">
<!-- Pour le responsive sur mobile -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>PolyMusic - TP3</title>
<title>Annales</title>
<!-- Déclaration de la feuille de style du document-->
<link rel="text/css" href="public/css/style.css">
<!-- Polyfills pour le support de fetch dans les vieux navigateurs -->
......@@ -26,7 +26,7 @@
</head>
<body>
Fais un effort là ! (╯°□°)╯︵ ┻━┻)
<p>Fais un effort là ! (╯°□°)╯︵ ┻━┻)</p>
</body>
</html>
\ No newline at end of file
......@@ -54,13 +54,12 @@ page('/', async function () {
await renderTemplate(templates('public/templates/signup.mustache'), context);
});
page('/p', async function () {
console.log('test?')
page('/signup', async function () {
await renderTemplate(templates('public/templates/signup.mustache'), context);
});
// On démarre le routing
page.base(window.location.pathname); // permet d'héberger la page sur une url autre de '/'
page.start();
// fonction utilitaire de rendu d'un template
......@@ -72,4 +71,4 @@ async function renderTemplate(template, context) {
// Et on l'insère dans le body
let body = document.querySelector('body');
body.innerHTML = rendered;
}
}
\ No newline at end of file
hey hey on va se créer un joli compte (●'◡'●)
\ No newline at end of file
hey hey on va se créer un joli compte (●'◡'●)
<form method="post" action="/api/users/add">
<label for="username">Nom d'utilisateur*</label>
<input type="text" id="username" name="user[username]" required>
<label for="password">Mot de passe*</label>
<input type="text" id="password" name="user[password]" required>
<label for="firstname">Prénom</label>
<input type="text" id="firstname" name="user[firstname]">
<label for="lastname">Nom</label>
<input type="text" id="lastname" name="user[lastname]">
<label for="email">Email</label>
<input type="email" id="email" name="user[email]">
<input type="submit" value="S'inscrire">
</form>
\ No newline at end of file
// les require
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const userRouter = require('./api/users/user.router');
// Le contenu statique public sera lu à partir du repertoire 'public'
app.use('/public', express.static('public'));
// On sert le contenu du répertoire storage_H par l'url /storage
app.use('/storage', express.static('storage_H'));
// propriétés
// je dis que je veux lire dans les formulaires
app.use(bodyParser.urlencoded({
extended: true
}));
// je passe les formulaires direct en json
app.use(bodyParser.json());
// on redirige ce qui vient de /api/users vers userRouter
app.use('/api/users', userRouter);
// Pour toutes les autres url (catch all) on renverra l'index.html
// c'est le routeur coté client qui fera alors le routing
app.use(function (req, res) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment