mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-10 04:22:18 +00:00
fix: more
This commit is contained in:
@@ -13,7 +13,7 @@ Create a function to build services you need in a file like `src/lib/server/appw
|
||||
As part of the function, set the current user's session if they are logged in. This is done by accessing the session cookie from the request and calling the `setSession(session)` with the cookie value.
|
||||
|
||||
{% info title="Appwrite client security" %}
|
||||
Notice that `createAppwriteClient` returns **a new instance** of the Appwrite Client.
|
||||
Notice that `createAdminClient` and `createSessionClient` returns **a new instance** of the Appwrite Client.
|
||||
When using Appwrite in server-integrations, it's important to **never share a `Client` instance** between two requests.
|
||||
Doing so could create security vulnerabilities.
|
||||
{% /info %}
|
||||
|
||||
@@ -12,7 +12,7 @@ We can now implement our sign up page. Create a `+page.svelte` file in the `src/
|
||||
<form method="post">
|
||||
<input id="email" placeholder="Email" type="email" />
|
||||
<input id="password" placeholder="Password" type="password" />
|
||||
<button type="submit">Sign in</button>
|
||||
<button type="submit">Sign up</button>
|
||||
</form>
|
||||
```
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ To redirect, add a button to our sign up page that redirects the user to the OAu
|
||||
|
||||
<!-- ... existing sign up form -->
|
||||
|
||||
<form action="/oauth2" method="post">
|
||||
<button type="submit">Sign in with GitHub</button>
|
||||
<form action="/oauth" method="post">
|
||||
<button type="submit">Sign up with GitHub</button>
|
||||
</form>
|
||||
```
|
||||
|
||||
@@ -39,7 +39,7 @@ export const actions = {
|
||||
|
||||
const redirectURL = account.createOAuth2Token(
|
||||
OAuthProvider.Github,
|
||||
`${event.url.origin}/oauth2`,
|
||||
`${event.url.origin}/oauth`,
|
||||
`${event.url.origin}/signup`
|
||||
);
|
||||
|
||||
@@ -48,12 +48,12 @@ export const actions = {
|
||||
};
|
||||
```
|
||||
|
||||
The `createOAuth2Token` method redirects the user to the OAuth provider, and then the OAuth provider redirects the user back to the `/oauth2` route with the `userId` and `secret` URL query parameters.
|
||||
The `createOAuth2Token` method redirects the user to the OAuth provider, and then the OAuth provider redirects the user back to the `/oauth` route with the `userId` and `secret` URL query parameters.
|
||||
|
||||
Handle the callback and create a session for the user. Create a new server route at `src/routes/oauth2/+server.js`:
|
||||
Handle the callback and create a session for the user. Create a new server route at `src/routes/oauth/+server.js`:
|
||||
|
||||
```js
|
||||
// src/routes/oauth2/+server.js
|
||||
// src/routes/oauth/+server.js
|
||||
|
||||
import { SESSION_COOKIE, createAdminClient } from '$lib/server/appwrite';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user