Skip to content

Commit 7cfe967

Browse files
authored
Merge pull request #59 from reynaldichernando/fix-first-init-puter
Fix first init puter module
2 parents 874ba09 + 2be2569 commit 7cfe967

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/modules/ProfileModule.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { BASE_URL, NULL_UUID, PROJECT_NAME, getHeaders, reconfigureURLs } from '
1010
// builtin
1111
import fs from 'node:fs';
1212
import crypto from 'node:crypto';
13+
import { initPuterModule } from './PuterModule.js';
1314

1415
// initializations
1516
const config = new Conf({ projectName: PROJECT_NAME });
@@ -39,6 +40,8 @@ class ProfileModule {
3940
if (!config.get('selected_profile')) {
4041
console.log(chalk.cyan('Please login first (or use CTRL+C to exit):'));
4142
await this.switchProfileWizard();
43+
// re init with new authToken
44+
initPuterModule();
4245
}
4346
this.applyProfileToGlobals();
4447
}

src/modules/PuterModule.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export const initPuterModule = () => {
1212
const profile = profiles.find((v) => v.uuid === uuid);
1313
const authToken = profile?.token;
1414

15-
puter.setAuthToken(authToken);
16-
puterModule = puter;
15+
if (authToken) {
16+
puter.setAuthToken(authToken);
17+
puterModule = puter;
18+
}
1719
};
1820

1921
/**

0 commit comments

Comments
 (0)