diff --git a/backend/controllers/accessToken.controller.ts b/backend/controllers/accessToken.controller.ts
index a9f2014..cdb44cc 100644
--- a/backend/controllers/accessToken.controller.ts
+++ b/backend/controllers/accessToken.controller.ts
@@ -10,11 +10,12 @@ export async function getAccessTokens(req: Request, res: Response) {
}
export async function createAccessToken(req: Request, res: Response) {
- const { name, token } = req.body;
+ const { name, token, tokenUsername } = req.body;
const username = (req as AuthenticatedRequest).user.username;
const accessToken = await AccessTokenService.createAccessToken(
name,
+ tokenUsername,
token,
username
);
diff --git a/backend/controllers/schedule.controller.ts b/backend/controllers/schedule.controller.ts
index 8ea6508..9dc5639 100644
--- a/backend/controllers/schedule.controller.ts
+++ b/backend/controllers/schedule.controller.ts
@@ -40,7 +40,7 @@ export async function createSchedule(req: Request, res: Response) {
repoUrl.href = repoUrl.href.replace(
"https://",
- `https://${accessToken.token}@`,
+ `https://${accessToken.tokenUsername}:${accessToken.token}@`,
);
}
diff --git a/backend/services/accessToken.service.ts b/backend/services/accessToken.service.ts
index c3bc074..7611d30 100644
--- a/backend/services/accessToken.service.ts
+++ b/backend/services/accessToken.service.ts
@@ -16,12 +16,14 @@ export class AccessTokenService {
}
static async createAccessToken(
name: string,
+ tokenUsername: string,
token: string,
username: string
) {
const accessToken = await prisma.accessToken.create({
data: {
name: name,
+ tokenUsername: tokenUsername,
token: token,
username: username,
},
diff --git a/package-lock.json b/package-lock.json
index 6706918..048a608 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "gitsave",
- "version": "1.3.0",
+ "version": "1.3.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gitsave",
- "version": "1.3.0",
+ "version": "1.3.3",
"dependencies": {
"@astrojs/check": "^0.9.3",
"@astrojs/react": "^3.6.2",
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index bda8046..9007285 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -41,6 +41,7 @@ model backupHistory {
model accessToken {
id Int @id @default(autoincrement())
+ tokenUsername String
token String
name String
user user @relation(fields: [username], references: [username])
diff --git a/src/components/dashboard/AddSchedulePopup.tsx b/src/components/dashboard/AddSchedulePopup.tsx
index ec55e1d..b2392f2 100644
--- a/src/components/dashboard/AddSchedulePopup.tsx
+++ b/src/components/dashboard/AddSchedulePopup.tsx
@@ -79,6 +79,7 @@ export default function AddSchedulePopup() {
const form = e.currentTarget;
const formData = new FormData(form);
const name = formData.get("access-token-name") as string;
+ const tokenUsername = formData.get("access-token-username") as string;
const token = formData.get("access-token") as string;
fetch("/api/access-tokens", {
@@ -86,7 +87,7 @@ export default function AddSchedulePopup() {
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ name, token }),
+ body: JSON.stringify({ name, tokenUsername, token }),
}).then(() => {
form.reset();
setShowAddAccessToken(false);
@@ -257,6 +258,13 @@ export default function AddSchedulePopup() {
name="access-token-name"
required
/>
+