-
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.
Merge pull request #5 from frorong/feature/oAuth
Add github oAuth
- Loading branch information
Showing
13 changed files
with
244 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { SvelteKitAuth } from '@auth/sveltekit' | ||
import GitHub from '@auth/sveltekit/providers/github' | ||
import { | ||
GITHUB_ID, | ||
GITHUB_SECRET, | ||
AUTH_SECRET, | ||
AUTH_TRUST_HOST, | ||
} from '$env/static/private' | ||
|
||
export const { | ||
handle, | ||
signIn, | ||
signOut, | ||
} = SvelteKitAuth({ | ||
providers: [ | ||
GitHub({ | ||
clientId: GITHUB_ID, | ||
clientSecret: GITHUB_SECRET, | ||
}), | ||
], | ||
secret: AUTH_SECRET, | ||
trustHost: Boolean(AUTH_TRUST_HOST), | ||
}) |
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,21 @@ | ||
<script lang="ts"> | ||
export let onClick: () => void | ||
</script> | ||
|
||
<button | ||
class="flex items-center justify-center rounded-md border border-gray-300 bg-gray-800 px-4 py-2 text-white outline-none hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2" | ||
on:click="{onClick}" | ||
> | ||
<svg | ||
class="mr-2 h-4 w-4" | ||
fill="currentColor" | ||
viewBox="0 0 16 16" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
fill-rule="evenodd" | ||
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" | ||
></path> | ||
</svg> | ||
Sign in with GitHub | ||
</button> |
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,21 @@ | ||
<script lang="ts"> | ||
export let onClick: () => void | ||
</script> | ||
|
||
<button | ||
class="flex items-center justify-center rounded-md border border-gray-300 bg-gray-800 px-4 py-2 text-white outline-none hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2" | ||
on:click="{onClick}" | ||
> | ||
<svg | ||
class="mr-2 h-4 w-4" | ||
fill="currentColor" | ||
viewBox="0 0 16 16" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
fill-rule="evenodd" | ||
d="M3.646 3.354a.5.5 0 00-.708 0l-2.5 2.5a.5.5 0 000 .708l2.5 2.5a.5.5 0 00.708-.708L2.707 6H8.5a.5.5 0 000-1H2.707l1.94-1.94a.5.5 0 000-.708zM9.5 0a.5.5 0 01.5.5v3a.5.5 0 01-1 0v-2.793l-1.146 1.147a.5.5 0 11-.708-.708l2-2A.5.5 0 019.5 0zM1 8.5a.5.5 0 01.5-.5H6a.5.5 0 010 1H1.5a.5.5 0 01-.5-.5zM8.5 10a.5.5 0 01.5.5v3a.5.5 0 01-1 0v-2.793l-1.146 1.147a.5.5 0 11-.708-.708l2-2A.5.5 0 018.5 10zM14 8.5a.5.5 0 01.5-.5H18a.5.5 0 010 1h-3.5a.5.5 0 01-.5-.5zM18 6h-5.793l1.147-1.146a.5.5 0 10-.708-.708l-2 2a.5.5 0 000 .708l2 2a.5.5 0 10.708-.708L12.707 6H18a.5.5 0 010 1z" | ||
></path> | ||
</svg> | ||
Logout | ||
</button> |
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 @@ | ||
export { handle } from './auth' |
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,6 @@ | ||
import type { LayoutServerLoad } from './$types' | ||
|
||
export const load: LayoutServerLoad = | ||
async (event) => ({ | ||
session: await event.locals.auth(), | ||
}) |
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,11 @@ | ||
import { redirect } from '@sveltejs/kit' | ||
import type { PageServerLoad } from './$types' | ||
|
||
export const load: PageServerLoad = | ||
async (event) => { | ||
const session = | ||
await event.locals.auth() | ||
if (!session?.user) | ||
throw redirect(303, '/auth') | ||
return {} | ||
} |
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,5 @@ | ||
import { signIn } from '../../auth' | ||
import type { Actions } from './$types' | ||
export const actions: Actions = { | ||
default: signIn, | ||
} |
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,5 @@ | ||
import { signOut } from '../../auth' | ||
import type { Actions } from './$types' | ||
export const actions: Actions = { | ||
default: signOut, | ||
} |
This file was deleted.
Oops, something went wrong.