Skip to content

Commit

Permalink
Merge pull request #79 from WildCodeSchool-2023-09/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Alexis-NM authored Jan 24, 2024
2 parents c3a5a63 + df99ab1 commit 043bcf8
Show file tree
Hide file tree
Showing 22 changed files with 564 additions and 84 deletions.
2 changes: 1 addition & 1 deletion backend/src/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load the express module to create a web application

// const path = require("path");
const express = require("express");

const app = express();
Expand Down
9 changes: 3 additions & 6 deletions backend/src/controllers/authControllers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { hash, argon2 } = require("argon2");
const { hash, verify, argon2id } = require("argon2");
const jwt = require("jsonwebtoken");
// Import access to database tables
const tables = require("../tables");
Expand All @@ -9,7 +9,7 @@ const add = (req, res) => {

// We create our hashing options
const hashingOptions = {
type: argon2.argon2id,
type: argon2id,
memoryCost: 2 ** 16,
timeCost: 5,
parallelism: 1,
Expand Down Expand Up @@ -45,10 +45,7 @@ const login = async (req, res, next) => {
return;
}

const verified = await argon2.verify(
user.hashed_password,
req.body.password
);
const verified = await verify(user.hashed_password, req.body.password);

if (verified) {
// Respond with the user in JSON format (but without the hashed password)
Expand Down
6 changes: 3 additions & 3 deletions backend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const express = require("express");
const router = express.Router();

const authControllers = require("./controllers/authControllers");
const { checkDatas } = require("./services/validateLogin");
// const { checkDatas } = require("./services/validateLogin");

const userControllers = require("./controllers/userControllers");
const { validateUser } = require("./services/validateUser");
const { verifyToken, hashPassword } = require("./services/auth");
const { hashPassword } = require("./services/auth");

const artworksControllers = require("./controllers/artworkControllers");
const { validateArtwork } = require("./services/validateArtwork");
Expand All @@ -24,7 +24,7 @@ const { validateCapture } = require("./services/validateCapture");
// Authentification routes

router.post("/register", authControllers.add);
router.post("/login", checkDatas, verifyToken, authControllers.login);
router.post("/login", authControllers.login);

// Routes of users
router.get("/users", userControllers.browse);
Expand Down
110 changes: 106 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
"dependencies": {
"@react-hook/media-query": "^1.1.1",
"axios": "^1.6.5",
"jwt-decode": "^4.0.0",
"leaflet": "^1.9.4",
"leaflet.locatecontrol": "^0.79.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-html5-camera-photo": "^1.5.11",
"react-leaflet": "^4.2.1",
"react-router-dom": "^6.14.2",
"sass": "^1.69.7"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Home from "./pages/Home";
import { Outlet } from "react-router-dom";
import "./styles/commons.scss";

function App() {
return <Home />;
return <Outlet />;
}

export default App;
16 changes: 16 additions & 0 deletions frontend/src/assets/Camera.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions frontend/src/assets/Upload.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions frontend/src/components/Camera.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { useState } from "react";
import CameraReact from "react-html5-camera-photo";
import "react-html5-camera-photo/build/css/index.css";
import CameraSVG from "../assets/Camera.svg";
import "./Camera.scss";

function Camera() {
const [isCameraOpen, setIsCameraOpen] = useState(false);

const handleTakePhoto = (dataUri) => {
// Faites quelque chose avec l'image capturée, par exemple, affichez-la ou téléchargez-la.
console.info(dataUri);
setIsCameraOpen(false);
};

const openCamera = () => {
setIsCameraOpen(true);
};

const closeCamera = () => {
setIsCameraOpen(false);
};

return (
<div>
{isCameraOpen ? (
<div>
<CameraReact onTakePhoto={handleTakePhoto} isFullscreen />
<button type="button" onClick={closeCamera}>
Fermer la caméra
</button>
</div>
) : (
<div>
<button
className="camera-button"
type="button"
onClick={openCamera}
onKeyDown={openCamera}
style={{ cursor: "pointer" }}
>
<img src={CameraSVG} alt="Camera icon" className="Camera-Icon" />
</button>
</div>
)}
</div>
);
}

export default Camera;
17 changes: 17 additions & 0 deletions frontend/src/components/Camera.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@import "../styles/commons.scss";

.camera-button {
background: none;
border: none;
padding: 0;
margin: 0;
font: inherit;
cursor: pointer;
outline: inherit;
}

.Camera-Icon {
width: 20vw;
margin-bottom: 30vh;
background-color: $deep-purple;
}
Loading

0 comments on commit 043bcf8

Please sign in to comment.