feat: log in with tumblr
This commit is contained in:
		
							parent
							
								
									d30ebacc72
								
							
						
					
					
						commit
						3338243cea
					
				
					 10 changed files with 342 additions and 9 deletions
				
			
		|  | @ -54,7 +54,9 @@ | |||
| 		"confirm-password-label": "Confirm password", | ||||
| 		"register-with-email-init-success": "Success! An email has been sent to your inbox, please press the link there to continue.", | ||||
| 		"register-with-google": "Register with a Google account", | ||||
| 		"remote-google-account-label": "Your Google account" | ||||
| 		"remote-google-account-label": "Your Google account", | ||||
| 		"register-with-tumblr": "Register with a Tumblr account", | ||||
| 		"remote-tumblr-account-label": "Your Tumblr account" | ||||
| 	}, | ||||
| 	"error": { | ||||
| 		"bad-request-header": "Something was wrong with your input", | ||||
|  |  | |||
|  | @ -3,8 +3,7 @@ | |||
| import type { Cookies } from "@sveltejs/kit"; | ||||
| import { DateTime } from "luxon"; | ||||
| 
 | ||||
| // export const TOKEN_COOKIE_NAME = "__Host-pronounscc-token";
 | ||||
| export const TOKEN_COOKIE_NAME = "pronounscc-token"; | ||||
| export const TOKEN_COOKIE_NAME = "__Host-pronounscc-token"; | ||||
| 
 | ||||
| export const setToken = (cookies: Cookies, token: string) => | ||||
| 	cookies.set(TOKEN_COOKIE_NAME, token, { path: "/" }); | ||||
|  |  | |||
|  | @ -0,0 +1,8 @@ | |||
| import createCallbackLoader from "$lib/actions/callback"; | ||||
| import createRegisterAction from "$lib/actions/register"; | ||||
| 
 | ||||
| export const load = createCallbackLoader("tumblr"); | ||||
| 
 | ||||
| export const actions = { | ||||
| 	default: createRegisterAction("/auth/tumblr/register"), | ||||
| }; | ||||
|  | @ -0,0 +1,31 @@ | |||
| <script lang="ts"> | ||||
| 	import Error from "$components/Error.svelte"; | ||||
| 	import NewAuthMethod from "$components/settings/NewAuthMethod.svelte"; | ||||
| 	import OauthRegistrationForm from "$components/settings/OauthRegistrationForm.svelte"; | ||||
| 	import { t } from "$lib/i18n"; | ||||
| 	import type { ActionData, PageData } from "./$types"; | ||||
| 
 | ||||
| 	type Props = { data: PageData; form: ActionData }; | ||||
| 	let { data, form }: Props = $props(); | ||||
| </script> | ||||
| 
 | ||||
| <svelte:head> | ||||
| 	<title>{$t("auth.register-with-tumblr")} • pronouns.cc</title> | ||||
| </svelte:head> | ||||
| 
 | ||||
| <div class="container"> | ||||
| 	{#if data.error} | ||||
| 		<h1>{$t("auth.register-with-tumblr")}</h1> | ||||
| 		<Error error={data.error} /> | ||||
| 	{:else if data.isLinkRequest} | ||||
| 		<NewAuthMethod method={data.newAuthMethod!} user={data.meUser!} /> | ||||
| 	{:else} | ||||
| 		<OauthRegistrationForm | ||||
| 			title={$t("auth.register-with-tumblr")} | ||||
| 			remoteLabel={$t("auth.remote-tumblr-account-label")} | ||||
| 			remoteUser={data.remoteUser!} | ||||
| 			ticket={data.ticket!} | ||||
| 			error={form?.error} | ||||
| 		/> | ||||
| 	{/if} | ||||
| </div> | ||||
|  | @ -0,0 +1,12 @@ | |||
| import { apiRequest } from "$api"; | ||||
| import { redirect } from "@sveltejs/kit"; | ||||
| 
 | ||||
| export const load = async ({ fetch, cookies }) => { | ||||
| 	const { url } = await apiRequest<{ url: string }>("GET", "/auth/tumblr/add-account", { | ||||
| 		isInternal: true, | ||||
| 		fetch, | ||||
| 		cookies, | ||||
| 	}); | ||||
| 
 | ||||
| 	redirect(303, url); | ||||
| }; | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue