Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback to github login if name is not available #23

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server/routes/auth/github.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ export default defineOAuthGitHubEventHandler({
return sendRedirect(event, '/login')
}

// Fall back to the user's login if the name is not available
const userName = oauthUser.name || oauthUser.login

// If the user is not signed in and no user exists with that GitHub ID or email address, create a new user
const createdUser = await createUser({
name: oauthUser.name as string,
name: userName as string,
email: oauthUser.email as string,
avatar: oauthUser.avatar_url as string,
githubId: oauthUser.id as number,
Expand Down
7 changes: 7 additions & 0 deletions server/routes/images/[...pathname].get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export default eventHandler(async (event) => {
const { pathname } = getRouterParams(event)

if (!pathname) {
return createError({
statusCode: 404,
statusMessage: 'Not Found',
})
}

return hubBlob().serve(event, pathname)
})
Loading