mufidu / booku

0 stars 1 forks source link

Sweep: Implement user authentication #72

Closed mufidu closed 7 months ago

mufidu commented 7 months ago

Details

Implement user authentication to allow users to have personalized book lists and preferences later.

Checklist - [X] Create `models/user.model.js` ✓ https://github.com/mufidu/booku/commit/f7bba2f5958331c71a76922a8b4417d8f56dcdf4 [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/models/user.model.js) - [X] Running GitHub Actions for `models/user.model.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/models/user.model.js) - [X] Create `middleware/auth.middleware.js` ✓ https://github.com/mufidu/booku/commit/5d7f8ca49feb9a31e49d1be1eb28e61a1d354524 [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/middleware/auth.middleware.js) - [X] Running GitHub Actions for `middleware/auth.middleware.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/middleware/auth.middleware.js) - [X] Create `routes/user.routes.js` ✓ https://github.com/mufidu/booku/commit/de7e0e39ff157827cf2834dcc53a598841730ad4 [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/routes/user.routes.js) - [X] Running GitHub Actions for `routes/user.routes.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/routes/user.routes.js) - [X] Modify `app.js` ✓ https://github.com/mufidu/booku/commit/c8f268e8ce027ab2ee15cba6bd28cb52ed853fbb [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/app.js) - [X] Running GitHub Actions for `app.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/app.js) - [X] Modify `package.json` ✓ https://github.com/mufidu/booku/commit/2ee6a330997e9263ab30040ad2114f05ffe11769 [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/package.json) - [X] Running GitHub Actions for `package.json` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/implement_user_authentication/package.json)
sweep-ai[bot] commented 7 months ago

🚀 Here's the PR! #73

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 5825790ddb)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/mufidu/booku/blob/068510c53f18d452bb85c14e0847de50572e5771/package.json#L1-L41

Step 2: ⌨️ Coding

Ran GitHub Actions for f7bba2f5958331c71a76922a8b4417d8f56dcdf4:

Ran GitHub Actions for 5d7f8ca49feb9a31e49d1be1eb28e61a1d354524:

Ran GitHub Actions for de7e0e39ff157827cf2834dcc53a598841730ad4:

--- 
+++ 
@@ -8,6 +8,9 @@
 const Book = require("./models/book");

 const morgan = require("morgan");
+const session = require('express-session');
+const userRoutes = require('./routes/user.routes.js');
+const authenticateToken = require('./middleware/auth.middleware.js');

 require("./db");
@@ -16,6 +19,18 @@
 app.use(express.json());
 app.use(methodOverride("_method"));
 app.use(morgan("dev"));
+
+app.use(session({
+  secret: 'secret',
+  resave: false,
+  saveUninitialized: true,
+  cookie: { secure: !process.env.NODE_ENV || process.env.NODE_ENV === 'development' ? false : true }
+}));
+
+app.use('/user', userRoutes);
+
+// Apply authentication middleware to protect routes
+app.use('/books', authenticateToken);

 const categories = Book.schema.path("category").enumValues;

Ran GitHub Actions for c8f268e8ce027ab2ee15cba6bd28cb52ed853fbb:

--- 
+++ 
@@ -20,6 +20,8 @@
   },
   "homepage": "https://github.com/mufidu/simplewebs#readme",
   "dependencies": {
+    "bcrypt": "^5.0.1",
+    "express-session": "^1.17.2",
     "eta": "^1.12.3",
     "express": "^4.17.2",
     "method-override": "^3.0.0",

Ran GitHub Actions for 2ee6a330997e9263ab30040ad2114f05ffe11769:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/implement_user_authentication.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.