mirror of
https://github.com/ION606/web-to-fish.git
synced 2026-05-14 18:36:53 +00:00
I give up
This commit is contained in:
@@ -4,7 +4,6 @@ import { fileURLToPath } from 'url';
|
||||
import session from 'express-session';
|
||||
import expressWs from 'express-ws';
|
||||
import { spawn } from 'node-pty';
|
||||
import linuxpam from 'node-linux-pam';
|
||||
import json from './secrets/config.json' with { type: 'json' };
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url)),
|
||||
@@ -53,22 +52,15 @@ app.post('/login', async (req, res) => {
|
||||
if (!username) return res.status(400).send('Username is required');
|
||||
if (!password) return res.status(400).send('Password is required');
|
||||
|
||||
// authenticate using PAM
|
||||
linuxpam.pamAuthenticate({
|
||||
username,
|
||||
password,
|
||||
serviceName: 'login',
|
||||
}, (err, success) => {
|
||||
console.log(err);
|
||||
if (err.message.includes('User not known')) res.sendStatus(404);
|
||||
else if (err.message.includes('Authentication failure')) res.sendStatus(401);
|
||||
else if (success) {
|
||||
req.session.authenticated = true;
|
||||
req.session.username = username;
|
||||
return res.redirect('/shell');
|
||||
}
|
||||
else console.error("what?", err, success);
|
||||
});
|
||||
const { uname, upass } = json;
|
||||
|
||||
if (username !== uname) return res.sendStatus(404);
|
||||
else if (password !== upass) return res.sendStatus(401);
|
||||
|
||||
req.session.authenticated = true;
|
||||
req.session.username = username;
|
||||
|
||||
return res.redirect('/shell');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).send('Internal server error');
|
||||
|
||||
Generated
+44
-1029
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -11,11 +11,13 @@
|
||||
"dependencies": {
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
"@xterm/xterm": "^5.5.0",
|
||||
"authenticate-pam": "^1.0.5",
|
||||
"express": "^4.21.2",
|
||||
"express-session": "^1.18.1",
|
||||
"express-ws": "^5.0.2",
|
||||
"node-linux-pam": "^0.2.1",
|
||||
"node-pty": "^1.0.0"
|
||||
"node-pty": "^1.0.0",
|
||||
"passport": "^0.7.0",
|
||||
"passport-local": "^1.0.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user