Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ajeasmith/auth-template-appwrite
auth template using Appwrite with Github OAuth
https://github.com/ajeasmith/auth-template-appwrite
Last synced: 18 days ago
JSON representation
auth template using Appwrite with Github OAuth
- Host: GitHub
- URL: https://github.com/ajeasmith/auth-template-appwrite
- Owner: AjeaSmith
- Created: 2024-10-31T19:52:56.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-05T01:50:11.000Z (about 2 months ago)
- Last Synced: 2024-11-05T02:33:35.802Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 491 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SSR Auth Starter using Appwrite (with Github OAuth)
## How to use this auth starter
- run ```npm i```
- Fill ```.env``` file with appwrite configs
- In appwrite, create API Key and set ```session.write``` permissions.
![set collection permissions](public/images/apikey.png)- [follow this YouTube video](https://www.youtube.com/watch?v=Bx1JqfPROXA) on how to setup a OAuth app in Github.
- all server actions are stored in ```@/lib/server/actions```## SSR Auth Flow
### Sign In Page
Checks for user session (```getLoggedInUser```). if it exist, user gets redirected to home page.
if no user, form will be submitted, using the ```signInWithEmail``` method
- store's the session in a cookie safely in the browser.
- creates the account in appwrite DB.
- redirects user to protected page### Header Component
Show's basic info about current user### Home Page Route
Checks for auth user, if not redirects to sign-up page### Additional Notes
- Inside Appwrite DB when working with collections, grant authenticated users permission to either Read, Write, Update or delete collections. If not, a 403 error will occur saying user doesn't have permission to access that collection.
*see image*
![set collection permissions](public/images/screenshot.png)- The **AdminClient** is used to make unauthenticated requests, its used when a new user needs to signs up and set a session
- The **SessionClient** is used to make authenticated requests, you need to have a valid session in order to make DB requests.