-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: removed old extensions * chore: auth is ready
- Loading branch information
1 parent
e0b1d71
commit 8d783fe
Showing
15 changed files
with
43 additions
and
216 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"prettier.enable": false, | ||
"editor.formatOnSave": false, | ||
|
||
"editor.codeActionsOnSave": { | ||
|
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,28 +1,12 @@ | ||
import jwt from 'jsonwebtoken' | ||
import type { WebsiteProfile } from '@chat-game/types' | ||
export default defineEventHandler(async (event) => { | ||
const session = await getUserSession(event) | ||
|
||
export default defineEventHandler((event) => { | ||
const { public: publicEnv, jwtSecretKey } = useRuntimeConfig() | ||
|
||
const token = getCookie(event, publicEnv.cookieKey) | ||
if (!token) { | ||
if (!session?.user) { | ||
throw createError({ | ||
statusCode: 401, | ||
statusMessage: 'Unauthorized', | ||
}) | ||
} | ||
|
||
try { | ||
const { profile } = jwt.verify(token, jwtSecretKey) as { profile: WebsiteProfile } | ||
return profile | ||
} catch (error) { | ||
if (error instanceof jwt.TokenExpiredError) { | ||
deleteCookie(event, publicEnv.cookieKey, { path: '/' }) | ||
} | ||
} | ||
|
||
throw createError({ | ||
statusCode: 401, | ||
statusMessage: 'Unauthorized', | ||
}) | ||
return session.user | ||
}) |
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 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
Oops, something went wrong.