From 2db6f16482607c64f13952b889c15840ef09ad42 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Mon, 4 Feb 2019 12:34:30 +0100 Subject: [PATCH] refactor(bitbucket): username/password overwrite token --- lib/config/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/config/index.js b/lib/config/index.js index d5f566a1af..6a474348e0 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -89,15 +89,15 @@ async function parseConfigs(env, argv) { } const endpoint = config.endpoint || platformInfo.endpoint; let token = config.token; + if (username && password) { + logger.info('Using username and password to generate token'); + const base64 = str => Buffer.from(str, 'binary').toString('base64'); + token = base64(`${username}:${password}`); + } if (!token) { - if (username && password) { - const base64 = str => Buffer.from(str, 'binary').toString('base64'); - token = base64(`${username}:${password}`); - } else { - throw new Error( - `No authentication found for platform ${endpoint} (${platform})` - ); - } + throw new Error( + `No authentication found for platform ${endpoint} (${platform})` + ); } config.hostRules.push({ platform, -- GitLab