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

Conversation

GreenmeisterDavid
Copy link
Contributor

Pull Request: Fallback Handling for Missing GitHub User Info and Minor TypeScript Fix

This PR solves Issue #22 by introducing a fallback mechanism for GitHub user names:

  • Fallback Logic:
    When no user name is provided (null), the system will:
    1. Fall back to the GitHub user's login
    2. If no login is available, fall back to the user's email prefix (everything before the @ symbol)
// Fallback to the user's login or email name if the name is not available
const userName = oauthUser.name || oauthUser.login || oauthUser.email.split('@')[0]

// 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: userName as string,
})

Additionally, this PR fixes a minor TypeScript issue that occurs during npx nuxi typecheck by ensuring a pathname exists in server/routes/images/[...pathname].get.ts:

export default eventHandler(async (event) => {
  const { pathname } = getRouterParams(event)

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

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

@Barbapapazes Barbapapazes changed the title Fix: GitHub login without username & minor typecheck issue fix: GitHub login without username & minor typecheck issue Oct 28, 2024
@Barbapapazes Barbapapazes changed the title fix: GitHub login without username & minor typecheck issue fix: fallback to github login if name is not available Oct 28, 2024
@Barbapapazes
Copy link
Owner

Hey 👋,

Thanks for this fix! 💜

@Barbapapazes Barbapapazes merged commit afd6421 into Barbapapazes:main Oct 28, 2024
1 check failed
@GreenmeisterDavid GreenmeisterDavid deleted the fix-github-login branch October 28, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants