Browse Source

fixup: lint errors

pull/914/head
Philip H. 1 year ago
committed by GitHub
parent
commit
b7c2c81cc7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 65
      src/lib/Server.js

65
src/lib/Server.js

@ -21,6 +21,7 @@ const {
setHeader,
serveStatic,
} = require('h3');
const Util = require('./Util');
const WireGuard = require('../services/WireGuard');
@ -67,42 +68,42 @@ module.exports = class Server {
return UI_TRAFFIC_STATS === 'true';
}))
// Authentication
.get('/api/session', defineEventHandler((event) => {
const requiresPassword = !!process.env.PASSWORD;
const authenticated = requiresPassword
? !!(event.node.req.session && event.node.req.session.authenticated)
: true;
return {
requiresPassword,
authenticated,
};
}))
.post('/api/session', defineEventHandler(async (event) => {
const { password } = await readBody(event);
if (typeof password !== 'string') {
throw createError({
status: 401,
message: 'Missing: Password',
});
}
// Authentication
.get('/api/session', defineEventHandler((event) => {
const requiresPassword = !!process.env.PASSWORD;
const authenticated = requiresPassword
? !!(event.node.req.session && event.node.req.session.authenticated)
: true;
return {
requiresPassword,
authenticated,
};
}))
.post('/api/session', defineEventHandler(async (event) => {
const { password } = await readBody(event);
if (typeof password !== 'string') {
throw createError({
status: 401,
message: 'Missing: Password',
});
}
if (password !== PASSWORD) {
throw createError({
status: 401,
message: 'Incorrect Password',
});
}
if (password !== PASSWORD) {
throw createError({
status: 401,
message: 'Incorrect Password',
});
}
event.node.req.session.authenticated = true;
event.node.req.session.save();
event.node.req.session.authenticated = true;
event.node.req.session.save();
debug(`New Session: ${event.node.req.session.id}`);
debug(`New Session: ${event.node.req.session.id}`);
return { succcess: true };
})));
return { succcess: true };
})));
// WireGuard
app.use(

Loading…
Cancel
Save