Skip to content

Commit 0496965

Browse files
Merge pull request #101 from ymichael/ymichael/fix-session-creation
Fix session create bug when passing in git credentials
2 parents da5e3f6 + 2636d47 commit 0496965

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/Sandboxes.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
SandboxListResponse,
2626
SandboxPrivacy,
2727
StartSandboxOpts,
28+
SessionCreateOptions,
2829
} from "./types";
2930
import { PitcherManagerResponse } from "@codesandbox/pitcher-client";
3031

@@ -75,21 +76,21 @@ export class Sandboxes {
7576
id: opts.templateId || this.defaultTemplateId,
7677
});
7778

78-
const session = await sandbox.connect(
79-
// We do not want users to pass gitAccessToken on global user, because it
80-
// can be read by other users
81-
{
82-
id: "clone-repo-user",
83-
permission: "write",
84-
...(opts.config
85-
? {
86-
gitAccessToken: opts.config.accessToken,
87-
email: opts.config.email,
88-
name: opts.config.name,
89-
}
90-
: {}),
91-
}
92-
);
79+
// We do not want users to pass gitAccessToken on global user, because it
80+
// can be read by other users
81+
const sessionCreateOptions: SessionCreateOptions = {
82+
id: "clone-repo-user",
83+
permission: "write",
84+
};
85+
if (opts.config) {
86+
sessionCreateOptions.git = {
87+
accessToken: opts.config.accessToken,
88+
email: opts.config.email,
89+
name: opts.config.name,
90+
};
91+
}
92+
93+
const session = await sandbox.connect(sessionCreateOptions);
9394

9495
await session.commands.run([
9596
"rm -rf .git",

0 commit comments

Comments
 (0)