mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: auth pages for mobile
This commit is contained in:
1 parent
435bd120c9
commit
2171d7f22d
7 files changed
+103
-20
No files matched your search
Generated
+6
-6
@@ -2940,9 +2940,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/devalue": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-4.0.0.tgz",
|
||||
"integrity": "sha512-w25siwXyuMUqMr7jPlEjyNCp1vn0Jzj/fNg3qVt/r/Dpe8HjESh2V92L0jmh3uq4iJt0BvjH+Azk1pQzkcnDWA==",
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-4.2.0.tgz",
|
||||
"integrity": "sha512-mbjoAaCL2qogBKgeFxFPOXAUsZchircF+B/79LD4sHH0+NHfYm8gZpQrskKDn5gENGt35+5OI1GUF7hLVnkPDw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/dir-glob": {
|
||||
@@ -9931,9 +9931,9 @@
|
||||
"peer": true
|
||||
},
|
||||
"devalue": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-4.0.0.tgz",
|
||||
"integrity": "sha512-w25siwXyuMUqMr7jPlEjyNCp1vn0Jzj/fNg3qVt/r/Dpe8HjESh2V92L0jmh3uq4iJt0BvjH+Azk1pQzkcnDWA==",
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-4.2.0.tgz",
|
||||
"integrity": "sha512-mbjoAaCL2qogBKgeFxFPOXAUsZchircF+B/79LD4sHH0+NHfYm8gZpQrskKDn5gENGt35+5OI1GUF7hLVnkPDw==",
|
||||
"dev": true
|
||||
},
|
||||
"dir-glob": {
|
||||
|
||||
+16
-14
@@ -46,23 +46,25 @@
|
||||
/**
|
||||
* Handle initial load.
|
||||
*/
|
||||
const acceptedRoutes = ['/login', '/register', '/recover', '/invite'];
|
||||
if ($user) {
|
||||
if (!$page.url.pathname.startsWith('/console')) {
|
||||
await goto(`${base}/console`, {
|
||||
replaceState: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (acceptedRoutes.includes($page.url.pathname)) {
|
||||
await goto(`${base}${$page.url.pathname}${$page.url.search}`);
|
||||
if (!$page.url.pathname.startsWith('/auth')) {
|
||||
const acceptedRoutes = ['/login', '/register', '/recover', '/invite'];
|
||||
if ($user) {
|
||||
if (!$page.url.pathname.startsWith('/console')) {
|
||||
await goto(`${base}/console`, {
|
||||
replaceState: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
await goto(`${base}/login`, {
|
||||
replaceState: true
|
||||
});
|
||||
if (acceptedRoutes.includes($page.url.pathname)) {
|
||||
await goto(`${base}${$page.url.pathname}${$page.url.search}`);
|
||||
} else {
|
||||
await goto(`${base}/login`, {
|
||||
replaceState: true
|
||||
});
|
||||
}
|
||||
}
|
||||
loading.set(false);
|
||||
}
|
||||
loading.set(false);
|
||||
});
|
||||
|
||||
afterNavigate((navigation) => {
|
||||
|
||||
@@ -8,6 +8,9 @@ import type { LayoutLoad } from './$types';
|
||||
export const ssr = false;
|
||||
|
||||
export const load: LayoutLoad = async ({ depends, url }) => {
|
||||
if (url.pathname.startsWith('/auth')) {
|
||||
return;
|
||||
}
|
||||
depends(Dependencies.ACCOUNT);
|
||||
try {
|
||||
const account = await sdkForConsole.account.get();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import { Container } from '$lib/layout';
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<slot />
|
||||
</Container>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Heading } from '$lib/components';
|
||||
import { Account, Client } from '@aw-labs/appwrite-console';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
const client = new Client();
|
||||
const account = new Account(client);
|
||||
|
||||
onMount(async () => {
|
||||
const projectId = $page.url.searchParams.get('project');
|
||||
client.setEndpoint(`${$page.url.origin}/v1`).setProject(projectId);
|
||||
|
||||
const userId = $page.url.searchParams.get('userId');
|
||||
const secret = $page.url.searchParams.get('secret');
|
||||
|
||||
await account.updateMagicURLSession(userId, secret);
|
||||
await goto(`appwrite-callback-${projectId}://${$page.url.search}`);
|
||||
});
|
||||
</script>
|
||||
|
||||
<Heading tag="h1" size="1">Missing Redirect URL</Heading>
|
||||
<p>
|
||||
Your Magic URL login flow is missing a proper redirect URL. Please check the
|
||||
<a href="https://appwrite.io/docs/client/account?sdk=web#createMagicURLSession"
|
||||
>Magic URL docs</a>
|
||||
and send request for new session with a valid redirect URL.
|
||||
</p>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Heading } from '$lib/components';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
onMount(async () => {
|
||||
const project = $page.url.searchParams.get('project');
|
||||
if (project) {
|
||||
await goto(`appwrite-callback-${project}://${$page.url.search}`);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<Heading tag="h1" size="1">Missing Redirect URL</Heading>
|
||||
<p class="text">
|
||||
Your OAuth login flow is missing a proper redirect URL. Please check the
|
||||
<a class="link" href="https://appwrite.io/docs/client/account?sdk=web#createOAuth2Session"
|
||||
>OAuth docs</a>
|
||||
and send request for new session with a valid callback URL.
|
||||
</p>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Heading } from '$lib/components';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
onMount(async () => {
|
||||
const project = $page.url.searchParams.get('project');
|
||||
if (project) {
|
||||
await goto(`appwrite-callback-${project}://${$page.url.search}`);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<Heading tag="h1" size="1">Missing Redirect URL</Heading>
|
||||
<p class="text">
|
||||
Your OAuth login flow is missing a proper redirect URL. Please check the
|
||||
<a class="link" href="https://appwrite.io/docs/client/account?sdk=web#createOAuth2Session"
|
||||
>OAuth docs</a>
|
||||
and send request for new session with a valid callback URL.
|
||||
</p>
|
||||
Reference in new issue
Block a user