Compare commits
3 Commits
8031ed1892
...
bfdbf6dedc
| Author | SHA1 | Date | |
|---|---|---|---|
| bfdbf6dedc | |||
| 707607f81c | |||
| 3de48ffac4 |
23
backend/.gitignore
vendored
Normal file
23
backend/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
15
backend/config/passport-setup.js
Normal file
15
backend/config/passport-setup.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
const passport = require('passport');
|
||||||
|
const LocalStrategy = require('passport-local').Strategy;
|
||||||
|
|
||||||
|
// Replace this with actual user verification logic
|
||||||
|
const verifyCallback = (username, password, done) => {
|
||||||
|
if (username === 'admin' && password === 'password') {
|
||||||
|
return done(null, { id: 1, username: 'admin' });
|
||||||
|
} else {
|
||||||
|
return done(null, false, { message: 'Invalid credentials' });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
passport.use(new LocalStrategy(verifyCallback));
|
||||||
|
passport.serializeUser((user, done) => done(null, user.id));
|
||||||
|
passport.deserializeUser((id, done) => done(null, { id, username: 'admin' }));
|
||||||
1134
backend/package-lock.json
generated
Normal file
1134
backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
backend/package.json
Normal file
19
backend/package.json
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "backend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"dockerode": "^4.0.2",
|
||||||
|
"express": "^4.19.2",
|
||||||
|
"express-session": "^1.18.0",
|
||||||
|
"passport": "^0.7.0",
|
||||||
|
"passport-local": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
17
backend/server.js
Normal file
17
backend/server.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// backend/server.js
|
||||||
|
const express = require('express');
|
||||||
|
const session = require('express-session');
|
||||||
|
const passport = require('passport');
|
||||||
|
const authRoutes = require('./routes/authRoutes');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
app.use(express.json());
|
||||||
|
app.use(session({ secret: 'your_secret', resave: false, saveUninitialized: false }));
|
||||||
|
app.use(passport.initialize());
|
||||||
|
app.use(passport.session());
|
||||||
|
|
||||||
|
app.use('/api/auth', authRoutes);
|
||||||
|
|
||||||
|
app.listen(3001, () => {
|
||||||
|
console.log('Backend server running on port 3001');
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user