-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add authentication with pocketbase (#6)
- Loading branch information
1 parent
9a42b27
commit 42b7580
Showing
37 changed files
with
666 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM alpine:latest | ||
|
||
ARG PB_VERSION=0.16.7 | ||
|
||
RUN apk add --no-cache \ | ||
unzip \ | ||
ca-certificates | ||
|
||
# download and unzip PocketBase | ||
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip | ||
RUN unzip /tmp/pb.zip -d /pb/ | ||
|
||
EXPOSE 8090 | ||
|
||
CMD [ "/pb/pocketbase", "serve", "--http=0.0.0.0:8090" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PUBLIC_POCKETBASE_URL="http://frontend.docker.localhost/pocketbase" | ||
PUBLIC_RELAY_URL="http://frontend.docker.localhost/relay" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
/build | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
!.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
<div style="display: contents">%sveltekit.body%</div> | ||
</body> | ||
|
||
</html> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script lang="ts"> | ||
import { currentUser, pb } from '$lib/pocketbase'; | ||
import { server } from '../stores/server'; | ||
import { Connect, Disconnect } from '../lib/grpc'; | ||
let password = ''; | ||
let username = ''; | ||
async function login() { | ||
await pb.collection('users').authWithPassword(username, password); | ||
await Connect($server, username, '0'); | ||
} | ||
function logout() { | ||
pb.authStore.clear(); | ||
Disconnect(); | ||
} | ||
</script> | ||
|
||
<div class="login"> | ||
{#if $currentUser} | ||
<p class="padding">Signed in as {$currentUser.username}</p> | ||
<button class="padding" on:click={logout}> Logout </button> | ||
{:else} | ||
<form class="padding" on:submit|preventDefault> | ||
<input type="text" bind:value={username} placeholder="Email" /> | ||
<input type="password" bind:value={password} placeholder="Password" /> | ||
<input type="text" bind:value={$server} /> | ||
<button on:click={login}> Login </button> | ||
</form> | ||
{/if} | ||
</div> | ||
|
||
<style> | ||
.login { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
} | ||
.padding { | ||
padding: 10px; | ||
} | ||
</style> |
Oops, something went wrong.