From ea25a45b35f4341d0fa2d7948e4cd2505bc868a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Vondra?= Date: Sun, 12 May 2019 14:44:27 +0200 Subject: [PATCH] Fix iOS and Android login (#50) * Update login.js Returning privateKey as null when is not found in the database. Otherwise, Bitwarden Mobile App gets an unexpected error and crashes without any log * eslint fixes --- src/login.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/login.js b/src/login.js index 7f4a6fe..554f700 100644 --- a/src/login.js +++ b/src/login.js @@ -148,6 +148,7 @@ export const handler = async (event, context, callback) => { device.set({ refreshToken: tokens.refreshToken }); device = await device.updateAsync(); + const privateKey = user.get('privateKey') || null; callback(null, utils.okResponse({ access_token: tokens.accessToken, @@ -155,7 +156,7 @@ export const handler = async (event, context, callback) => { token_type: 'Bearer', refresh_token: tokens.refreshToken, Key: user.get('key'), - PrivateKey: (user.get('privateKey') || '').toString('utf8'), + PrivateKey: privateKey ? privateKey.toString('utf8') : null, })); } catch (e) { callback(null, utils.serverError('Internal error', e));