mirror of
https://github.com/caprover/caprover
synced 2026-08-28 18:36:31 +00:00
Refactor on validateAuthentication method
This commit is contained in:
+3
-10
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user