la-flowerita 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. package/README.md +70 -0
  2. package/package.json +78 -0
  3. package/public/favicon.ico +0 -0
  4. package/public/images/1.jpg +0 -0
  5. package/public/images/2.jpg +0 -0
  6. package/public/images/3.jpg +0 -0
  7. package/public/images/Logo.png +0 -0
  8. package/public/images/add-user.png +0 -0
  9. package/public/images/contact-us.png +0 -0
  10. package/public/images/flower.png +0 -0
  11. package/public/images/flower_shop.png +0 -0
  12. package/public/images/flower_shop1.png +0 -0
  13. package/public/images/flowers/buttercup.png +0 -0
  14. package/public/images/flowers/daffodil.png +0 -0
  15. package/public/images/flowers/daisy.png +0 -0
  16. package/public/images/flowers/jasmine.png +0 -0
  17. package/public/images/flowers/lily.png +0 -0
  18. package/public/images/flowers/marigold.png +0 -0
  19. package/public/images/flowers/orchid.png +0 -0
  20. package/public/images/flowers/rose.png +0 -0
  21. package/public/images/flowers/sunflower.png +0 -0
  22. package/public/images/flowers/tulip.png +0 -0
  23. package/public/images/garbage.png +0 -0
  24. package/public/images/icon1.jpg +0 -0
  25. package/public/images/login.png +0 -0
  26. package/public/images/refresh.png +0 -0
  27. package/public/images/transaction.png +0 -0
  28. package/public/index.html +41 -0
  29. package/public/logo192.png +0 -0
  30. package/public/logo512.png +0 -0
  31. package/public/manifest.json +26 -0
  32. package/public/offline.html +44 -0
  33. package/public/robots.txt +3 -0
  34. package/public/serviceworker.js +44 -0
  35. package/server.js +97 -0
  36. package/src/App.css +38 -0
  37. package/src/App.js +25 -0
  38. package/src/App.test.js +8 -0
  39. package/src/Config/db.js +5 -0
  40. package/src/Config/mail.js +7 -0
  41. package/src/Config/passport.js +34 -0
  42. package/src/Controllers/catalog.controller.js +78 -0
  43. package/src/Controllers/shoppinglist.controller.js +186 -0
  44. package/src/Controllers/user.controller.js +214 -0
  45. package/src/Controllers/wishlist.controller.js +150 -0
  46. package/src/Middleware/sendMail.js +29 -0
  47. package/src/Middleware/uploadImage.js +26 -0
  48. package/src/Models/orderProducts.js +10 -0
  49. package/src/Models/products.js +17 -0
  50. package/src/Models/shoppinglists.js +12 -0
  51. package/src/Models/userShoppinglists.js +9 -0
  52. package/src/Models/users.js +57 -0
  53. package/src/Models/wishlists.js +9 -0
  54. package/src/Routes/auth.js +21 -0
  55. package/src/Routes/indexRouter.js +40 -0
  56. package/src/Services/ProductService.js +76 -0
  57. package/src/Services/ShoppinglistService.js +135 -0
  58. package/src/Services/UserService.js +63 -0
  59. package/src/Services/WishlistService.js +105 -0
  60. package/src/components/About.js +45 -0
  61. package/src/components/Auth.js +15 -0
  62. package/src/components/Catalog.js +118 -0
  63. package/src/components/Chat.js +77 -0
  64. package/src/components/Contact.js +48 -0
  65. package/src/components/Dashboard.js +13 -0
  66. package/src/components/DetailsProductModal.js +362 -0
  67. package/src/components/LoginModal.js +173 -0
  68. package/src/components/NewProductModal.js +271 -0
  69. package/src/components/NoPermission.js +10 -0
  70. package/src/components/OrderedProduct.js +104 -0
  71. package/src/components/PreChat.js +51 -0
  72. package/src/components/Product.js +158 -0
  73. package/src/components/ResetPassword.js +211 -0
  74. package/src/components/ShoppingCart.js +198 -0
  75. package/src/components/SideNav.js +76 -0
  76. package/src/components/SignupModal.js +306 -0
  77. package/src/components/Spinner.js +22 -0
  78. package/src/components/Wishlist.js +195 -0
  79. package/src/components/social-config.js +17 -0
  80. package/src/css/about.css +12 -0
  81. package/src/css/catalog.css +218 -0
  82. package/src/css/chat.css +191 -0
  83. package/src/css/contact.css +404 -0
  84. package/src/css/index.css +129 -0
  85. package/src/css/newProductModal.css +69 -0
  86. package/src/css/noPermission.css +89 -0
  87. package/src/css/orderedProduct.css +0 -0
  88. package/src/css/resetPassword.css +44 -0
  89. package/src/css/shoppingCart.css +10 -0
  90. package/src/css/sideNav.css +68 -0
  91. package/src/css/spinner.css +23 -0
  92. package/src/images/1.jpg +0 -0
  93. package/src/images/2.jpg +0 -0
  94. package/src/images/3.jpg +0 -0
  95. package/src/images/Logo.png +0 -0
  96. package/src/images/add-user.png +0 -0
  97. package/src/images/buttercup.png +0 -0
  98. package/src/images/contact-us.png +0 -0
  99. package/src/images/daffodil.png +0 -0
  100. package/src/images/daisy.png +0 -0
  101. package/src/images/flower.png +0 -0
  102. package/src/images/flower_shop.png +0 -0
  103. package/src/images/flower_shop1.png +0 -0
  104. package/src/images/flowers/buttercup.png +0 -0
  105. package/src/images/flowers/daffodil.png +0 -0
  106. package/src/images/flowers/daisy.png +0 -0
  107. package/src/images/flowers/jasmine.png +0 -0
  108. package/src/images/flowers/lily.png +0 -0
  109. package/src/images/flowers/marigold.png +0 -0
  110. package/src/images/flowers/orchid.png +0 -0
  111. package/src/images/flowers/rose.png +0 -0
  112. package/src/images/flowers/sunflower.png +0 -0
  113. package/src/images/flowers/tulip.png +0 -0
  114. package/src/images/garbage.png +0 -0
  115. package/src/images/icon1.jpg +0 -0
  116. package/src/images/jasmine.png +0 -0
  117. package/src/images/lily.png +0 -0
  118. package/src/images/login.png +0 -0
  119. package/src/images/marigold.png +0 -0
  120. package/src/images/orchid.png +0 -0
  121. package/src/images/refresh.png +0 -0
  122. package/src/images/rose.png +0 -0
  123. package/src/images/sunflower.png +0 -0
  124. package/src/images/transaction.png +0 -0
  125. package/src/images/tulip.png +0 -0
  126. package/src/index.js +371 -0
  127. package/src/logo.svg +1 -0
  128. package/src/reportWebVitals.js +13 -0
  129. package/src/setupTests.js +5 -0
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13
+
14
+ The page will reload when you make changes.\
15
+ You may also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35
+
36
+ If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39
+
40
+ You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
47
+
48
+ ### Code Splitting
49
+
50
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51
+
52
+ ### Analyzing the Bundle Size
53
+
54
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55
+
56
+ ### Making a Progressive Web App
57
+
58
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59
+
60
+ ### Advanced Configuration
61
+
62
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63
+
64
+ ### Deployment
65
+
66
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67
+
68
+ ### `npm run build` fails to minify
69
+
70
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "la-flowerita",
3
+ "version": "0.1.0",
4
+ "dependencies": {
5
+ "@fortawesome/fontawesome-svg-core": "^6.1.2",
6
+ "@fortawesome/free-solid-svg-icons": "^6.1.2",
7
+ "@fortawesome/react-fontawesome": "^0.2.0",
8
+ "@testing-library/jest-dom": "^5.16.4",
9
+ "@testing-library/react": "^13.3.0",
10
+ "@testing-library/user-event": "^13.5.0",
11
+ "bootstrap": "^5.2.0",
12
+ "build": "^0.1.4",
13
+ "connect-mongo": "^4.6.0",
14
+ "cors": "^2.8.5",
15
+ "dotenv": "^16.0.1",
16
+ "express": "^4.18.1",
17
+ "express-jwt": "^7.7.5",
18
+ "express-session": "^1.17.3",
19
+ "http": "^0.0.1-security",
20
+ "jquery": "^3.6.0",
21
+ "jsonwebtoken": "^8.5.1",
22
+ "mongodb": "^4.8.0",
23
+ "mongoose": "^6.4.4",
24
+ "multer": "^1.4.5-lts.1",
25
+ "multer-gridfs-storage": "^5.0.2",
26
+ "node": "^18.7.0",
27
+ "nodemailer": "^6.7.8",
28
+ "nodemon": "^2.0.19",
29
+ "npm": "^8.17.0",
30
+ "passport": "^0.6.0",
31
+ "passport-local": "^1.0.0",
32
+ "react": "^18.1.0",
33
+ "react-bootstrap": "^2.4.0",
34
+ "react-bootstrap-icons": "^1.8.4",
35
+ "react-confirm-alert": "^3.0.6",
36
+ "react-dom": "^18.1.0",
37
+ "react-icons": "^4.4.0",
38
+ "react-loader-spinner": "^5.1.7-beta.1",
39
+ "react-modal-login": "^2.0.7",
40
+ "react-pro-sidebar": "^0.7.1",
41
+ "react-promise-tracker": "^2.1.0",
42
+ "react-rating-stars-component": "^2.2.0",
43
+ "react-router-dom": "^6.3.0",
44
+ "react-scripts": "^5.0.1",
45
+ "react-scroll-to-bottom": "^4.2.0",
46
+ "run": "^1.4.0",
47
+ "save": "^2.5.0",
48
+ "socket.io": "^4.5.1",
49
+ "socket.io-client": "^4.5.1",
50
+ "sweetalert": "^2.1.2",
51
+ "utf8": "^3.0.0",
52
+ "web-vitals": "^2.1.4"
53
+ },
54
+ "scripts": {
55
+ "start": "react-scripts start",
56
+ "build": "react-scripts build",
57
+ "test": "react-scripts test",
58
+ "eject": "react-scripts eject"
59
+ },
60
+ "eslintConfig": {
61
+ "extends": [
62
+ "react-app",
63
+ "react-app/jest"
64
+ ]
65
+ },
66
+ "browserslist": {
67
+ "production": [
68
+ ">0.2%",
69
+ "not dead",
70
+ "not op_mini all"
71
+ ],
72
+ "development": [
73
+ "last 1 chrome version",
74
+ "last 1 firefox version",
75
+ "last 1 safari version"
76
+ ]
77
+ }
78
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Flowers Shop</title>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+
8
+ <!-- Bootstrap core CSS -->
9
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css">
10
+ <link rel="stylesheet" href="https://getbootstrap.com/docs/5.2/components/navbar/">
11
+ <link rel="stylesheet" href="https://getbootstrap.com/docs/5.2/components/modal/">
12
+ <link rel="stylesheet" href="../assets/dist/css/bootstrap.min.css">
13
+ <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
14
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
15
+
16
+ <!-- <link rel="stylesheet" href="css/index.css">-->
17
+
18
+ <!-- JavaScript Bundle with Popper -->
19
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js"></script>
20
+ <!-- jQuery -->
21
+ <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
22
+ <!-- Ajax -->
23
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
24
+
25
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
26
+ <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
27
+ </head>
28
+ <link rel="stylesheet" href="https://getbootstrap.com/docs/3.3/dist/css/bootstrap.min.css">
29
+
30
+ <div id="root"></div>
31
+
32
+ <script>
33
+ if('serviceWorker' in navigator){
34
+ window.addEventListener('load', () => {
35
+ navigator.serviceWorker.register('./serviceworker.js')
36
+ .then((reg) => {console.log('Success: ', reg.scope)})
37
+ .catch((err) => {console.log('Failure: ', err)});
38
+ })
39
+ }
40
+ </script>
41
+ </html>
Binary file
Binary file
@@ -0,0 +1,26 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon",
9
+ "purpose": "maskable any"
10
+ },
11
+ {
12
+ "src": "logo192.png",
13
+ "type": "image/png",
14
+ "sizes": "192x192"
15
+ },
16
+ {
17
+ "src": "logo512.png",
18
+ "type": "image/png",
19
+ "sizes": "512x512"
20
+ }
21
+ ],
22
+ "start_url": ".",
23
+ "display": "standalone",
24
+ "theme_color": "#000000",
25
+ "background_color": "#ffffff"
26
+ }
@@ -0,0 +1,44 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Flowers Shop</title>
7
+ <style type="text/css">
8
+ html {
9
+ height: 100%;
10
+ }
11
+ body {
12
+ height: 100%;
13
+ margin: 0;
14
+ background: #0a1f44;
15
+ display: flex;
16
+ align-items: center;
17
+ text-align: center;
18
+ justify-content: center;
19
+ }
20
+
21
+ .city {
22
+ align-items: center;
23
+ width: 80%;
24
+ display: flex;
25
+ justify-content: center;
26
+ flex-direction: column;
27
+ padding: 40px 8%;
28
+ border-radius: 20px;
29
+ background: #fff;
30
+ }
31
+
32
+ .city-name {
33
+ font-size: 2em;
34
+ }
35
+ </style>
36
+ </head>
37
+ <body>
38
+ <div class="city">
39
+ <h2 class="city-name">
40
+ <span>Please go online.</span>
41
+ </h2>
42
+ </div>
43
+ </body>
44
+ </html>
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,44 @@
1
+ const CACHE_NAME = "version-1";
2
+ const urlsToCache = [ 'index.html', 'offline.html' ];
3
+
4
+ const self = this;
5
+
6
+ // Install SW
7
+ self.addEventListener('install', (event) => {
8
+ event.waitUntil(
9
+ caches.open(CACHE_NAME)
10
+ .then((cache) => {
11
+ console.log('Opened cache');
12
+
13
+ return cache.addAll(urlsToCache);
14
+ })
15
+ )
16
+ });
17
+
18
+ // Listen for requests
19
+ self.addEventListener('fetch', (event) => {
20
+ event.respondWith(
21
+ caches.match(event.request)
22
+ .then(() => {
23
+ return fetch(event.request)
24
+ .catch(() => caches.match('offline.html'))
25
+ })
26
+ )
27
+ });
28
+
29
+ // Activate the SW
30
+ self.addEventListener('activate', (event) => {
31
+ const cacheWhitelist = [];
32
+ cacheWhitelist.push(CACHE_NAME);
33
+
34
+ event.waitUntil(
35
+ caches.keys().then((cacheNames) => Promise.all(
36
+ cacheNames.map((cacheName) => {
37
+ if(!cacheWhitelist.includes(cacheName)) {
38
+ return caches.delete(cacheName);
39
+ }
40
+ })
41
+ ))
42
+
43
+ )
44
+ });
package/server.js ADDED
@@ -0,0 +1,97 @@
1
+ const express = require("express");
2
+ const app = express();
3
+ const cors = require("cors");
4
+ const path = require("path");
5
+ var bodyParser = require("body-parser");
6
+ var jsonParser = bodyParser.json()
7
+ var mongoose = require("mongoose");
8
+
9
+ require("./src/Models/users");
10
+ require("./src/Models/products");
11
+ require("./src/Models/orderProducts");
12
+ require("./src/Models/shoppinglists");
13
+ require("./src/Models/userShoppinglists");
14
+
15
+ const dbConfig = require("./src/Config/db");
16
+
17
+ // AUTHENTIATION
18
+ const expressSession = require('express-session');
19
+ const MongoStore = require('connect-mongo');
20
+ const session = expressSession(
21
+ { secret: 'secret',
22
+ algorithms: ['RS256'],
23
+ cookie: { maxAge: 60 * 60 * 24 * 1000 },
24
+ resave: false,
25
+ saveUninitialized: false,
26
+ // store: MongoStore.create({
27
+ // mongoUrl: 'mongodb://localhost/FlowersShop', //YOUR MONGODB URL
28
+ // ttl: 15 * 60 * 1000 ,
29
+ // autoRemove: 'native'
30
+ // })
31
+ })
32
+ app.use(session);
33
+ const passport = require('passport');
34
+ const LocalStrategy = require('passport-local')
35
+ app.use(passport.initialize())
36
+ app.use(passport.session());
37
+ require("./src/Config/passport");
38
+
39
+
40
+ // const uri = "mongodb://tratzon:tratzon1@cluster0-shard-00-00.l39y0.mongodb.net:27017,cluster0-shard-00-01.l39y0.mongodb.net:27017,Users-shard-00-02.l39y0.mongodb.net:27017/FlowersShop?ssl=true&replicaSet=atlas-2i336t-shard-0&authSource=admin&retryWrites=true&w=majority";
41
+ const uri = dbConfig.url;
42
+ mongoose.connect(uri, {
43
+ keepAlive: true,
44
+ useNewUrlParser: true,
45
+ useUnifiedTopology: true,
46
+ })
47
+ .then(x => {
48
+ console.log(
49
+ `Connected to Mongo! Database name: "${x.connections[0].name}"`,
50
+ );
51
+ })
52
+ .catch(err => {
53
+ console.error('Error connecting to mongo', err);
54
+ });
55
+
56
+
57
+ app.use(express.static(path.join(__dirname, "/public")));
58
+
59
+ indexRouter = require("./src/Routes/indexRouter");
60
+ app.use("/", indexRouter);
61
+
62
+
63
+ // Connection to the socket
64
+ const http = require("http");
65
+ const { Server } = require("socket.io");
66
+ app.use(cors());
67
+ const server = http.createServer(app);
68
+ const io = new Server(server, {
69
+ cors: {
70
+ origin: "http://localhost:3000",
71
+ methods: ["GET", "POST"],
72
+ },
73
+ });
74
+
75
+
76
+
77
+ io.on('connection', function(socket) {
78
+ console.log(`User Connected: ${socket.id}`);
79
+
80
+ socket.on("join_room", (data) => {
81
+ socket.join(data);
82
+ console.log(`User with ID: ${socket.id} joined room: ${data}`);
83
+ });
84
+
85
+ socket.on("send_message", (data) => {
86
+ socket.to(data.room).emit("receive_message", data);
87
+ });
88
+
89
+ socket.on("disconnect", () => {
90
+ console.log("User Disconnected", socket.id);
91
+ });
92
+ })
93
+
94
+ const port = 5000;
95
+ server.listen(port, () => {
96
+ console.log(`Server Running on port ${port}!`);
97
+ });
package/src/App.css ADDED
@@ -0,0 +1,38 @@
1
+ .App {
2
+ text-align: center;
3
+ }
4
+
5
+ .App-logo {
6
+ height: 40vmin;
7
+ pointer-events: none;
8
+ }
9
+
10
+ @media (prefers-reduced-motion: no-preference) {
11
+ .App-logo {
12
+ animation: App-logo-spin infinite 20s linear;
13
+ }
14
+ }
15
+
16
+ .App-header {
17
+ background-color: #282c34;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ justify-content: center;
23
+ font-size: calc(10px + 2vmin);
24
+ color: white;
25
+ }
26
+
27
+ .App-link {
28
+ color: #61dafb;
29
+ }
30
+
31
+ @keyframes App-logo-spin {
32
+ from {
33
+ transform: rotate(0deg);
34
+ }
35
+ to {
36
+ transform: rotate(360deg);
37
+ }
38
+ }
package/src/App.js ADDED
@@ -0,0 +1,25 @@
1
+ import logo from './logo.svg';
2
+ import './App.css';
3
+
4
+ function App() {
5
+ return (
6
+ <div className="App">
7
+ <header className="App-header">
8
+ <img src={logo} className="App-logo" alt="logo" />
9
+ <p>
10
+ Edit <code>src/App.js</code> and save to reload.
11
+ </p>
12
+ <a
13
+ className="App-link"
14
+ href="https://reactjs.org"
15
+ target="_blank"
16
+ rel="noopener noreferrer"
17
+ >
18
+ Learn React
19
+ </a>
20
+ </header>
21
+ </div>
22
+ );
23
+ }
24
+
25
+ export default App;
@@ -0,0 +1,8 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import App from './App';
3
+
4
+ test('renders learn react link', () => {
5
+ render(<App />);
6
+ const linkElement = screen.getByText(/learn react/i);
7
+ expect(linkElement).toBeInTheDocument();
8
+ });
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ url: "mongodb://tratzon:tratzon1@cluster0-shard-00-00.l39y0.mongodb.net:27017,cluster0-shard-00-01.l39y0.mongodb.net:27017,Users-shard-00-02.l39y0.mongodb.net:27017/FlowersShop?ssl=true&replicaSet=atlas-2i336t-shard-0&authSource=admin&retryWrites=true&w=majority",
3
+ database: "FlowersShop",
4
+ collectionUsers: "images",
5
+ };
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ SERVICE: "gmail",
3
+ SMTP_EMAIL: "ratzontalya11@gmail.com",
4
+ SMTP_PASSWORD: "wnvqbiiidlibcmnp",
5
+ FROM_NAME: "FlowersShop",
6
+ FROM_EMAIL: "ratzontalya11@gmail.com"
7
+ };
@@ -0,0 +1,34 @@
1
+ const mongoose = require('mongoose');
2
+ const passport = require('passport');
3
+ const LocalStrategy = require('passport-local').Strategy;
4
+
5
+ const UserService = require("../Services/UserService");
6
+ const Users = mongoose.model('Users');
7
+
8
+ passport.use(new LocalStrategy({
9
+ usernameField: 'email',
10
+ passwordField: 'password',
11
+ }, (email, password, done) => {
12
+ Users.findOne({ email })
13
+ .then((user) => {
14
+ if(!user || !user.validatePassword(password)) {
15
+ return done(null, false, { status: 404 });
16
+ }
17
+ user = {_id: user._id, email:user.email};
18
+ console.log("logged " + JSON.stringify(user));
19
+ return done(null, user);
20
+ }).catch(done);
21
+ }));
22
+
23
+
24
+ passport.serializeUser( (userObj, done) => {
25
+ console.log("serializeUser")
26
+ console.log(userObj);
27
+ done(null, userObj)
28
+ })
29
+
30
+ passport.deserializeUser((userObj, done) => {
31
+ console.log("derializeUser")
32
+ done (null, userObj )
33
+ })
34
+