Skip to content
Snippets Groups Projects
Commit 5287344d authored by Mamadu-lamarana Bah's avatar Mamadu-lamarana Bah :speech_balloon:
Browse files

gestion coté client des utilisateurs pour accès au spectacle

parent 9221d690
Branches
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@
<div id="content">
<div id="tickets"> <strong>Liste des tickets :</strong>
<div class="showDesc"> </div>
<div id="showTickets"> </div>
</div>
<div id="shows"> <strong>spectacles :</strong>
......
......@@ -78,7 +78,7 @@ const createShow =
const response = await fetch('/admin/new/', requestOptions);
if (response.ok) {
const createdShow = await response.json();
displayMessage(`${createdShow._id} créée`);
displayMessage(`${createdShow.description} créée`);
resetDesc();
displayList();
}
......
......@@ -43,14 +43,14 @@ const displayList = async () => {
const addToList = (show,list) => {
const node = document.createElement('div');
node.className = 'show';
node.id = show._id;
node.textContent = `${show.description} (${show.places})`;
//
//node.addEventListener('mouseover', () => getTask(show._id));
//
const ticketsButton = document.createElement('button');
ticketsButton.className = 'ticket';
ticketsButton.addEventListener('click', () => ajoutTicketShow(show._id));
ticketsButton.addEventListener('click', ajoutTicketShow);
ticketsButton.textContent = '+1 tickets';
node.appendChild(ticketsButton);
//
......@@ -76,8 +76,15 @@ const update = async () => {
}
}
const ajoutTicketShow = async showId => {
const ajoutTicketShow = async (event) => {
const divShow = event.target.parentElement;
const showId = divShow.id;
const divTickets = document.getElementById("showTickets");
// const buttons = divShow.getElementsByClassName("ticket");
// buttons.forEach( button => {
// button.textContent = "annuler";
// button.removeEventListener("click", ajoutTicketShow);
// })
};
const logout = async () => {
......
......@@ -55,7 +55,7 @@ const login = async (req, res) => {
return res.status(401).json({ message : 'mot de passe incorrect.'});
// create and send token
const token = jwt.sign({id: user._id}, jwtConfig.SECRET_TOKEN, {expiresIn : '120s'} );
const token = jwt.sign({id: user._id}, jwtConfig.SECRET_TOKEN, {expiresIn : '500s'} );
console.log(`login : ${token}`);
res.cookie('token', token, { maxAge : 60000, httpOnly: true, sameSite : 'strict' }) // secure : true (avec https)
res.status(200).json({ message : 'utilisateur connecté', name : user.name, admin : user.admin });
......
......@@ -18,8 +18,9 @@ const userSchema = new mongoose.Schema({
default: false
},
reservedTickets: [{
spectacle: { type: mongoose.ObjectId, ref: 'Shows' },
seatsReserved: { type: Number, required: true }
show: { type: mongoose.ObjectId},
description : { type : String, unique :true, required : true},
tickets: { type: Number, required: true }
}]
});
......
......@@ -5,7 +5,7 @@
<title>user profile</title>
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css"/>
<script defer src="../scripts/admin-bundle.js?9971186e0e86954b9bf1"></script></head>
<script defer src="../scripts/admin-bundle.js?0d71f7f58236f8f7a2fc"></script></head>
<body>
<h1>Application Showtime</h1>
......
......@@ -5,7 +5,7 @@
<title>login/register</title>
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css"/>
<script defer src="../scripts/login-bundle.js?9971186e0e86954b9bf1"></script></head>
<script defer src="../scripts/login-bundle.js?0d71f7f58236f8f7a2fc"></script></head>
<body>
<h1>Application de partage</h1>
......
......@@ -5,7 +5,7 @@
<title>login/register</title>
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css"/>
<script defer src="../scripts/register-bundle.js?9971186e0e86954b9bf1"></script></head>
<script defer src="../scripts/register-bundle.js?0d71f7f58236f8f7a2fc"></script></head>
<body>
<h1>Identification</h1>
......
......@@ -5,7 +5,7 @@
<title>user profile</title>
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css"/>
<script defer src="../scripts/user-bundle.js?9971186e0e86954b9bf1"></script></head>
<script defer src="../scripts/user-bundle.js?0d71f7f58236f8f7a2fc"></script></head>
<body>
<h1>Application Showtime</h1>
......@@ -23,7 +23,7 @@
<div id="content">
<div id="tickets"> <strong>Liste des tickets :</strong>
<div class="showDesc"> </div>
<div id="showTickets"> </div>
</div>
<div id="shows"> <strong>spectacles :</strong>
......
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment