mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-28 02:18:01 -04:00
Fix token parsing + start of device registering
This commit is contained in:
@@ -258,13 +258,14 @@ impl Runner {
|
||||
exp: DateTime<Utc>,
|
||||
}
|
||||
|
||||
token_decoding_buffer.clear();
|
||||
|
||||
// The format of a JWT token is simple:
|
||||
// "<base64-encoded header>.<base64-encoded claims>.<signature>"
|
||||
BASE64_URL_SAFE_NO_PAD.decode_vec(
|
||||
token.split('.').nth(1).ok_or(Error::MissingClaims)?,
|
||||
token_decoding_buffer,
|
||||
)?;
|
||||
token_decoding_buffer.clear();
|
||||
|
||||
serde_json::from_slice::<Token>(token_decoding_buffer)?
|
||||
.exp
|
||||
|
||||
@@ -1,29 +1,49 @@
|
||||
import { Envelope } from '@phosphor-icons/react';
|
||||
import { Card } from '@sd/ui';
|
||||
import { getAccessToken } from 'supertokens-web-js/recipe/session';
|
||||
import { useBridgeMutation } from '@sd/client';
|
||||
import { Button, Card } from '@sd/ui';
|
||||
import { TruncatedText } from '~/components';
|
||||
import { AuthRequiredOverlay } from '~/components/AuthRequiredOverlay';
|
||||
|
||||
const Profile = ({ email }: { email?: string }) => {
|
||||
const emailName = email?.split('@')[0];
|
||||
const capitalizedEmailName = (emailName?.charAt(0).toUpperCase() ?? '') + emailName?.slice(1);
|
||||
const cloudBootstrap = useBridgeMutation('cloud.bootstrap');
|
||||
|
||||
return (
|
||||
<Card className="relative flex w-full flex-col items-center justify-center !p-0 lg:max-w-[320px]">
|
||||
{/* <AuthRequiredOverlay /> */}
|
||||
<div className="p-3">
|
||||
<h1 className="mx-auto mt-3 text-lg">
|
||||
Welcome <span className="font-bold">{capitalizedEmailName},</span>
|
||||
</h1>
|
||||
<div className="mx-auto mt-4 flex w-full flex-col gap-2">
|
||||
<Card className="w-full items-center justify-start gap-1 bg-app-input !px-2">
|
||||
<div className="w-[20px]">
|
||||
<Envelope weight="fill" width={20} />
|
||||
</div>
|
||||
<TruncatedText>{email}</TruncatedText>
|
||||
</Card>
|
||||
<div className="flex flex-col gap-5">
|
||||
<Card className="relative flex w-full flex-col items-center justify-center !p-0 lg:max-w-[320px]">
|
||||
{/* <AuthRequiredOverlay /> */}
|
||||
<div className="p-3">
|
||||
<h1 className="mx-auto mt-3 text-lg">
|
||||
Welcome <span className="font-bold">{capitalizedEmailName},</span>
|
||||
</h1>
|
||||
<div className="mx-auto mt-4 flex w-full flex-col gap-2">
|
||||
<Card className="w-full items-center justify-start gap-1 bg-app-input !px-2">
|
||||
<div className="w-[20px]">
|
||||
<Envelope weight="fill" width={20} />
|
||||
</div>
|
||||
<TruncatedText>{email}</TruncatedText>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</Card>
|
||||
<h2 className="mx-auto mt-4 text-sm">DEBUG</h2>
|
||||
<Button
|
||||
className="mt-4 w-full"
|
||||
onClick={async () => {
|
||||
const accessToken = (await getAccessToken()) ?? '';
|
||||
const refreshToken: string =
|
||||
JSON.parse(window.localStorage.getItem('frontendCookies') ?? '[]')
|
||||
.find((cookie: string) => cookie.startsWith('st-refresh-token'))
|
||||
?.split('=')[1]
|
||||
.split(';')[0] || '';
|
||||
|
||||
cloudBootstrap.mutate([accessToken.trim(), refreshToken.trim()]);
|
||||
}}
|
||||
>
|
||||
Start Cloud Bootstrap
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
1
packages/client/src/core.ts
generated
1
packages/client/src/core.ts
generated
@@ -69,7 +69,6 @@ export type Procedures = {
|
||||
{ key: "cloud.devices.update", input: DeviceUpdateRequest, result: null } |
|
||||
{ key: "cloud.libraries.create", input: LibraryArgs<AccessToken>, result: null } |
|
||||
{ key: "cloud.libraries.delete", input: LibraryArgs<AccessToken>, result: null } |
|
||||
{ key: "cloud.libraries.sync", input: LibraryArgs<null>, result: null } |
|
||||
{ key: "cloud.libraries.update", input: LibraryArgs<LibrariesUpdateArgs>, result: null } |
|
||||
{ key: "cloud.locations.create", input: LocationCreateRequest, result: null } |
|
||||
{ key: "cloud.locations.delete", input: LocationDeleteRequest, result: null } |
|
||||
|
||||
Reference in New Issue
Block a user