Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/project-sync.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const MAX_REQUEST_ALLOWED_TIME = 5 * 60 * 1000;
const loggerLabel = 'project-sync-service';
let remoteBaseCommitId = '';
let WM_PLATFORM_VERSION = '';
let isAuthenticated = false;

async function findProjectId(config) {
const projectList = (await axios.get(`${config.baseUrl}/edn-services/rest/users/projects/list`,
Expand Down Expand Up @@ -142,6 +143,17 @@ async function gitResetAndPull(tempDir, projectDir){
}

async function pullChanges(projectId, config, projectDir) {
isAuthenticated = await checkAuthCookie(config);

if (!isAuthenticated) {
console.log(chalk.yellow('\n⚠ Authentication Required'));
console.log(chalk.gray('━'.repeat(50)));
console.log(chalk.white('\nYour session has expired. Please authenticate to continue.'));
console.log(chalk.cyan(`\n→ Generate token: ${config.baseUrl}/studio/services/auth/token\n`));
config.authCookie = await authenticateWithToken(config, false);
global.localStorage.setItem(STORE_KEY, config.authCookie);
}

try {
const output = await exec('git', ['rev-parse', 'HEAD'], {
cwd: projectDir
Expand Down Expand Up @@ -363,7 +375,7 @@ async function setup(previewUrl, projectName, authToken) {
appPreviewUrl: previewUrl,
projectName: projectName
};
const isAuthenticated = await checkAuthCookie(config);
isAuthenticated = await checkAuthCookie(config);
if (!isAuthenticated) {
//console.log(`Need to login to Studio (${config.baseUrl}). \n Please enter your Studio credentails.`);
//config.authCookie = await authenticateWithUserNameAndPassword(config);
Expand Down