Skip to content

Commit d6973e1

Browse files
WMS-30135 | fix: improve authentication handling in project sync for pulling new changes
1 parent 5667fc3 commit d6973e1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/project-sync.service.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const MAX_REQUEST_ALLOWED_TIME = 5 * 60 * 1000;
1818
const loggerLabel = 'project-sync-service';
1919
let remoteBaseCommitId = '';
2020
let WM_PLATFORM_VERSION = '';
21+
let isAuthenticated = false;
2122

2223
async function findProjectId(config) {
2324
const projectList = (await axios.get(`${config.baseUrl}/edn-services/rest/users/projects/list`,
@@ -142,6 +143,13 @@ async function gitResetAndPull(tempDir, projectDir){
142143
}
143144

144145
async function pullChanges(projectId, config, projectDir) {
146+
isAuthenticated = await checkAuthCookie(config);
147+
148+
if (!isAuthenticated) {
149+
config.authCookie = await authenticateWithToken(config, true);
150+
global.localStorage.setItem(STORE_KEY, config.authCookie);
151+
}
152+
145153
try {
146154
const output = await exec('git', ['rev-parse', 'HEAD'], {
147155
cwd: projectDir
@@ -363,7 +371,7 @@ async function setup(previewUrl, projectName, authToken) {
363371
appPreviewUrl: previewUrl,
364372
projectName: projectName
365373
};
366-
const isAuthenticated = await checkAuthCookie(config);
374+
isAuthenticated = await checkAuthCookie(config);
367375
if (!isAuthenticated) {
368376
//console.log(`Need to login to Studio (${config.baseUrl}). \n Please enter your Studio credentails.`);
369377
//config.authCookie = await authenticateWithUserNameAndPassword(config);

0 commit comments

Comments
 (0)