From d6de81370bb2e11432af3d2804d0e86134c5804b Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sun, 26 Dec 2021 16:53:57 -0400 Subject: [PATCH] Simplify --- src/routes.js | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/routes.js b/src/routes.js index 11baa06f..ef5cd5a3 100644 --- a/src/routes.js +++ b/src/routes.js @@ -629,12 +629,7 @@ module.exports = async ( const publicKey = await GunDB.authenticate(alias, password) if (!publicKey) { - res.status(401).json({ - field: 'alias', - errorMessage: 'Invalid alias/password combination', - success: false - }) - return false + throw new Error('Invalid alias/password combination') } const [isKeyTrusted = !trustedKeysEnabled] = (trustedKeys || []).filter( @@ -655,13 +650,9 @@ module.exports = async ( !isKeyTrusted && !allowUnlockedLND ) { - res.status(401).json({ - field: 'alias', - errorMessage: - 'Invalid alias/password combination (Untrusted Device)', - success: false - }) - return + throw new Error( + 'Invalid alias/password combination (Untrusted Device)' + ) } if (walletUnlocked && !isKeyTrusted && !allowUnlockedLND) { @@ -670,13 +661,9 @@ module.exports = async ( ) if (!validatedToken) { - res.status(401).json({ - field: 'alias', - errorMessage: - 'Invalid alias/password combination (Untrusted Auth Token)', - success: false - }) - return + throw new Error( + 'Invalid alias/password combination (Untrusted Auth Token)' + ) } }