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
32 changes: 32 additions & 0 deletions public/images/cursor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"neovim": "Download Testaustime for Neovim",
"title": "Extensions",
"vscode": "Download Testaustime for Visual Studio Code",
"cursor": "Download Testaustime for Cursor",
"sublime": "Download Testaustime for Sublime Text"
},
"footer": {
Expand Down Expand Up @@ -308,7 +309,9 @@
}
},
"authorize": {
"body": "You are logging in to the official Visual Studio Code extension.",
"body": "You are logging in to the official {{editor}} extension.",
"invalidEditor": "This editor is invalid.",
"unsupportedEditor": "This editor is not supported.",
"continue": "Continue as {{username}}",
"notWorking": {
"text": "Not working?",
Expand Down
5 changes: 4 additions & 1 deletion public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"extensions": {
"body": "Lataa Testaustime-laajennus suosikkieditorillesi!",
"cursor": "Lataa Testaustime Cursor:lle",
"intellij": "Lataa Testaustime IntelliJ:lle",
"micro": "Lataa Testaustime Micro:lle",
"neovim": "Lataa Testaustime Neovim:lle",
Expand Down Expand Up @@ -308,7 +309,9 @@
}
},
"authorize": {
"body": "Olet kirjautumassa sisään viralliseen Visual Studio Code -lisäosaan.",
"body": "Olet kirjautumassa sisään viralliseen {{editor}} -lisäosaan.",
"invalidEditor": "Tämä editori on virheellinen.",
"unsupportedEditor": "Tätä editoria ei tueta.",
"continue": "Jatka käyttäjänä {{username}}",
"notWorking": {
"text": "Eikö toimi?",
Expand Down
44 changes: 38 additions & 6 deletions src/app/[locale]/authorize/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,55 @@ export default async function AuthorizePage({
}) {
const { t } = await initTranslations(locale, ["common"]);

const loginUrl =
editor == "vscode"
? `/login?redirect=${encodeURIComponent("/authorize?editor=vscode")}`
: "/login";
const loginUrls = new Map(
Object.entries({
vscode: `/login?redirect=${encodeURIComponent("/authorize?editor=vscode")}`,
cursor: `/login?redirect=${encodeURIComponent("/authorize?editor=cursor")}`,
}),
);
const loginUrl = loginUrls.get(editor ?? "vscode");

if (loginUrl === undefined) {
// Make this prettier
return <div>{t("authorize.unsupportedEditor")}</div>;
}

const token = cookies().get("token")?.value;
if (!token) {
redirect(loginUrl);
}

const redirectUrls = new Map(
Object.entries({
vscode: `vscode://testausserveri-ry.testaustime/authorize?token=${token}`,
cursor: `cursor://testausserveri-ry.testaustime-cursor/authorize?token=${token}`,
}),
);
const redirectUrl = redirectUrls.get(editor ?? "vscode");
if (redirectUrl === undefined) {
// Make this prettier
return <div>{t("authorize.unsupportedEditor")}</div>;
}

const me = await getMe();
if (!me || "error" in me) {
redirect(loginUrl);
}

const { username } = me;

const editorNames = new Map(
Object.entries({
vscode: "Visual Studio Code",
cursor: "Cursor",
}),
);
const editorName = editorNames.get(editor ?? "vscode");

if (editorName === undefined) {
return <div>{t("authorize.invalidEditor")}</div>;
}

return (
<Stack align="center" gap="xl">
<Image
Expand All @@ -40,10 +72,10 @@ export default async function AuthorizePage({
width={40}
height={40}
/>
<Text>{t("authorize.body")}</Text>
<Text>{t("authorize.body", { editor: editorName })}</Text>
<Button
component="a"
href={`vscode://testausserveri-ry.testaustime/authorize?token=${token}`}
href={redirectUrl}
>
{t("authorize.continue", { username })}
</Button>
Expand Down
7 changes: 7 additions & 0 deletions src/app/[locale]/extensions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export default async function ExtensionsPage({
sourceCodeLink="https://github.com/Testausserveri/testaustime-vscode"
text={t("extensions.vscode")}
/>
<ExtensionBlock
logo="/images/cursor.svg"
alt="Cursor logo"
downloadLink="https://marketplace.visualstudio.com/items?itemName=testausserveri-ry.testaustime-cursor"
sourceCodeLink="https://github.com/Testausserveri/testaustime-cursor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the repo in process of being moved under Testaustime (or at least Testausserveri) organization? At least I didn't see any messages in Discord about that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. we'll talk about that in discord.

text={t("extensions.cursor")}
/>
<ExtensionBlock
logo="/images/neovim.svg"
alt="Neovim logo"
Expand Down
1 change: 1 addition & 0 deletions src/components/LoginForm/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const allowedRedirects = [
"/friends",
"/leaderboards",
"/authorize?editor=vscode",
"/authorize?editor=cursor",
];

export const logIn = async (
Expand Down