Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion backend/controllers/accessToken.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/schedule.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}@`,
);
}

Expand Down
2 changes: 2 additions & 0 deletions backend/services/accessToken.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
10 changes: 9 additions & 1 deletion src/components/dashboard/AddSchedulePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ 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", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ name, token }),
body: JSON.stringify({ name, tokenUsername, token }),
}).then(() => {
form.reset();
setShowAddAccessToken(false);
Expand Down Expand Up @@ -257,6 +258,13 @@ export default function AddSchedulePopup() {
name="access-token-name"
required
/>
<BaseInput
type="text"
label="Username"
placeholder="Enter access token username"
name="access-token-username"
required
/>
<BaseInput
type="password"
label="Token"
Expand Down