Skip to content

Commit

Permalink
feat(#673): migrate to AuthJS
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix-ru committed Oct 8, 2024
1 parent a070447 commit c609509
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 462 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
"ufo": "^1.5.4"
},
"peerDependencies": {
"next-auth": "~4.21.1"
"@auth/core": "^0.35.2"
},
"devDependencies": {
"@antfu/eslint-config": "^2.25.0",
"@auth/core": "^0.35.2",
"@nuxt/module-builder": "^0.8.3",
"@nuxt/schema": "^3.12.4",
"@nuxtjs/eslint-config-typescript": "^12.1.0",
Expand Down
10 changes: 4 additions & 6 deletions playground-authjs/server/api/auth/[...].ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import CredentialsProvider from 'next-auth/providers/credentials'
import GithubProvider from 'next-auth/providers/github'
import CredentialsProvider from '@auth/core/providers/credentials'
import GithubProvider from '@auth/core/providers/github'
import { NuxtAuthHandler } from '#auth'

export default NuxtAuthHandler({
// a) Never hardcode your secret in your code!! and b) use a secure secret, `test-123` is **not** secure!!
secret: process.env.AUTH_SECRET ?? 'test-123',
providers: [
// @ts-expect-error You need to use .default here for it to work during SSR. May be fixed via Vite at some point
GithubProvider.default({
GithubProvider({
clientId: process.env.GITHUB_CLIENT_ID ?? 'your-client-id',
clientSecret: process.env.GITHUB_CLIENT_SECRET ?? 'your-client-secret'
}),
// @ts-expect-error You need to use .default here for it to work during SSR. May be fixed via Vite at some point
CredentialsProvider.default({
CredentialsProvider({
// The name to display on the sign in form (e.g. 'Sign in with...')
name: 'Credentials',
// The credentials is used to generate a suitable form on the sign in page.
Expand Down
Loading

0 comments on commit c609509

Please sign in to comment.