Refactor on validateAuthentication method

This commit is contained in:
Daniel Treviño
2018-12-11 20:18:47 +01:00
parent 4b1a2ab6b6
commit 38ff3077cb
2 changed files with 7 additions and 10 deletions
+3 -10
View File
@@ -22,9 +22,6 @@ async function deployAsDefaultValues() {
const isValidAuthentication = await validateAuthentication()
if (isValidAuthentication) {
// REFACTOR - Refresh token in DeployApi
initMachineFromLocalStorage()
const { appName, branchToPush, machineToDeploy } = DeployApi
if (!appName || !branchToPush || !machineToDeploy) {
@@ -60,9 +57,6 @@ async function deployAsStateless(host, appName, branch, pass) {
// Update the token to the machine that corresponds (if needed)
MachineHelper.updateMachineAuthToken(name, newToken)
// REFACTOR - Refresh token in DeployApi
initMachineFromLocalStorage()
if (data) {
printMessage(
`Starting stateless deploy to\n${host}\n${branch}\n${appName}`
@@ -207,13 +201,12 @@ async function deploy(options) {
const isValidAuthentication = await validateAuthentication()
if (isValidAuthentication) {
// REFACTOR - Refresh token in DeployApi
initMachineFromLocalStorage()
deployFromGitProject()
} else {
printError("Incorrect login details", true)
}
} catch (e) {
printError("Incorrect login details", true)
printError(e.message, true)
}
}
}
+4
View File
@@ -2,6 +2,7 @@ const fs = require("fs-extra")
const DeployApi = require("../api/DeployApi")
const { printError } = require("./messageHandler")
const { requestLogin } = require("../lib/login")
const { initMachineFromLocalStorage } = require("../utils/machineUtils")
function validateIsGitRepository() {
const gitFolderExists = fs.pathExistsSync("./.git")
@@ -89,6 +90,9 @@ async function validateAuthentication() {
if (!isAuthenticated) {
const loggedInStatus = await requestLogin()
// Refresh token in DeployApi
initMachineFromLocalStorage()
return loggedInStatus
} else {
return Boolean(isAuthenticated)