-
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.
Adding the FP approach to the middleware
- Loading branch information
1 parent
9864146
commit aca3226
Showing
13 changed files
with
371 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { PUBLIC_AUTH0_DOMAIN } from '$env/static/public'; | ||
|
||
import { type AuthUserProfile, AuthUserProfileSchema } from '$lib/types'; | ||
|
||
export async function fetchAuthUser({ | ||
accessToken | ||
}: { | ||
accessToken: string; | ||
}): Promise<AuthUserProfile> { | ||
const resp = await fetch(`https://${PUBLIC_AUTH0_DOMAIN}/userinfo`, { | ||
headers: { | ||
Authorization: `Bearer ${accessToken}` | ||
} | ||
}); | ||
|
||
if (resp.ok) { | ||
const profile = await resp.json(); | ||
return AuthUserProfileSchema.parse(profile); | ||
} | ||
|
||
const text = await resp.text(); | ||
throw new Error(`Failed to fetch auth user. Resp: ${text}, Status: ${resp.status}`); | ||
} |
File renamed without changes.
File renamed without changes.
Empty file.
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
Oops, something went wrong.