Browse Source

Server.js: Fix login flow

pull/750/head
Daniil Isakov 3 years ago
parent
commit
3eb046f08c
  1. 8
      src/lib/Server.js

8
src/lib/Server.js

@ -53,15 +53,17 @@ module.exports = class Server {
const { password } = ctx.request.body;
if (typeof password !== 'string') {
throw new ServerError('Missing: Password', 401);
ctx.throw(401, JSON.stringify({ error: 'Missing: Password' }));
}
if (password !== PASSWORD) {
throw new ServerError('Incorrect Password', 401);
ctx.throw(401, JSON.stringify({ error: 'Incorrect Password' }));
}
ctx.session.authenticated = true;
ctx.status = 204;
debug(`New Session: ${ctx.session.id}`);
})
@ -96,6 +98,8 @@ module.exports = class Server {
ctx.session = null;
ctx.status = 204;
debug(`Deleted Session: ${sessionId}`);
})
.get('/api/wireguard/client', async (ctx) => {

Loading…
Cancel
Save