diff --git a/core/auth.js b/core/auth.js index d8ecac1c..69e12f06 100644 --- a/core/auth.js +++ b/core/auth.js @@ -116,12 +116,20 @@ function getCookies(headers) { function handler(request, response) { let session = getCookies(request.headers).session; if (request.uri == "/login") { + let formData = form.decodeForm(request.query); + if (query(request.headers)?.permissions?.authenticated) { + if (formData.return) { + response.writeHead(303, {"Location": formData.return}); + } else { + response.writeHead(303, {"Location": (request.client.tls ? 'https://' : 'http://') + request.headers.host + '/', "Content-Length": "0"}); + } + response.end(); + return; + } + let sessionIsNew = false; let loginError; - let formData = form.decodeForm(request.query); - - print(request.method, utf8Decode(request.body), JSON.stringify(formData)); if (request.method == "POST" || formData.submit) { sessionIsNew = true; formData = form.decodeForm(utf8Decode(request.body), formData);