From ec3bbb27e8e6dfc886b59837cdad131cfc7e08b3 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Thu, 2 Jun 2022 14:45:39 +0300 Subject: [PATCH] fix: fix netlify funcs status codes --- functions/login/login.js | 4 ++++ functions/logout/logout.js | 1 + 2 files changed, 5 insertions(+) diff --git a/functions/login/login.js b/functions/login/login.js index 6f663a2..3dd7238 100644 --- a/functions/login/login.js +++ b/functions/login/login.js @@ -18,6 +18,7 @@ async function generateAuthUrl() { async function login(tag, k1, sig, key) { if (tag !== 'login') { return { + statusCode: 400, body: JSON.stringify({ status: 'ERROR', reason: 'Not a login request' }) } } @@ -26,6 +27,7 @@ async function login(tag, k1, sig, key) { await LnurlService.verifySig(sig, k1, key) } catch (error) { return { + statusCode: 400, body: JSON.stringify({ status: 'ERROR', reason: 'Invalid Signature' }) } } @@ -71,6 +73,7 @@ async function login(tag, k1, sig, key) { return { + statusCode: 200, 'headers': { 'Set-Cookie': authCookie, 'Cache-Control': 'no-cache', @@ -81,6 +84,7 @@ async function login(tag, k1, sig, key) { } } catch (error) { return { + statusCode: 200, body: JSON.stringify({ status: 'ERROR', reason: 'Unexpected error happened, please try again' }) } diff --git a/functions/logout/logout.js b/functions/logout/logout.js index 77c038b..58f66a6 100644 --- a/functions/logout/logout.js +++ b/functions/logout/logout.js @@ -9,6 +9,7 @@ exports.handler = async (event, context) => { maxAge: -1, }) return { + statusCode: 200, body: JSON.stringify({ status: 'OK', }),