feat: link fediverse account to existing user
This commit is contained in:
parent
03209e4028
commit
57e1ec09c0
17 changed files with 335 additions and 95 deletions
|
@ -0,0 +1,37 @@
|
|||
import { apiRequest } from "$api";
|
||||
import { redirect } from "@sveltejs/kit";
|
||||
|
||||
export const actions = {
|
||||
add: async ({ request, fetch, cookies }) => {
|
||||
const body = await request.formData();
|
||||
const instance = body.get("instance") as string;
|
||||
|
||||
const { url } = await apiRequest<{ url: string }>(
|
||||
"GET",
|
||||
`/auth/fediverse/add-account?instance=${encodeURIComponent(instance)}`,
|
||||
{
|
||||
isInternal: true,
|
||||
fetch,
|
||||
cookies,
|
||||
},
|
||||
);
|
||||
|
||||
redirect(303, url);
|
||||
},
|
||||
forceRefresh: async ({ request, fetch, cookies }) => {
|
||||
const body = await request.formData();
|
||||
const instance = body.get("instance") as string;
|
||||
|
||||
const { url } = await apiRequest<{ url: string }>(
|
||||
"GET",
|
||||
`/auth/fediverse/add-account?instance=${encodeURIComponent(instance)}&forceRefresh=true`,
|
||||
{
|
||||
isInternal: true,
|
||||
fetch,
|
||||
cookies,
|
||||
},
|
||||
);
|
||||
|
||||
redirect(303, url);
|
||||
},
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { Button, Input, InputGroup } from "@sveltestrap/sveltestrap";
|
||||
</script>
|
||||
|
||||
<h3>Link a new Fediverse account</h3>
|
||||
|
||||
<form method="POST" action="?/add">
|
||||
<InputGroup>
|
||||
<Input
|
||||
name="instance"
|
||||
type="text"
|
||||
placeholder={$t("auth.log-in-with-fediverse-instance-placeholder")}
|
||||
/>
|
||||
<Button type="submit" color="secondary">{$t("auth.log-in-button")}</Button>
|
||||
</InputGroup>
|
||||
<p>
|
||||
{$t("auth.log-in-with-fediverse-error-blurb")}
|
||||
<Button formaction="?/forceRefresh" type="submit" color="link">
|
||||
{$t("auth.log-in-with-fediverse-force-refresh-button")}
|
||||
</Button>
|
||||
</p>
|
||||
</form>
|
Loading…
Add table
Add a link
Reference in a new issue