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(#967): allow signUp endpoint to be disabled #968

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

root5427
Copy link

πŸ”— Linked issue

#967

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Documentation states that signUp endpoint may be disabled by setting it to false:

You can customize each endpoint to fit your needs or disable it by setting it to `false`. For example you may want to disable the `signUp` endpoint.
```ts{6}
export default defineNuxtConfig({
auth: {
provider: {
type: 'local',
endpoints: {
signUp: false
}
}
}
})
```

But if you try to do this, you will get the following typescript error in your IDE:

Type 'false' has no properties in common with type '{ path?: string | undefined; method?: "head" | "get" | "patch" | "post" | "put" | "delete" | "connect" | "options" | "trace" | undefined; }'. ts(2559)

And the case where signUp endpoint is disabled is not handled by the signUp function of the useAuth composable:

async function signUp(credentials: Credentials, signInOptions?: SecondarySignInOptions, signUpOptions?: SignUpOptions) {
const nuxt = useNuxtApp()
const { path, method } = useTypedBackendConfig(useRuntimeConfig(), 'local').endpoints.signUp
await _fetch(nuxt, path, {
method,
body: credentials
})
if (signUpOptions?.preventLoginFlow) {
return
}
return signIn(credentials, signInOptions)
}

This PR should fix these issues.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

@root5427 root5427 changed the title fix(967): allow signUp endpoint to be disabled fix(#967): allow signUp endpoint to be disabled Dec 23, 2024
Copy link

pkg-pr-new bot commented Dec 23, 2024

Open in Stackblitz

npm i https://pkg.pr.new/@sidebase/nuxt-auth@968

commit: 8410502

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