Skip to content

Commit

Permalink
Use server side signIn/signOut
Browse files Browse the repository at this point in the history
  • Loading branch information
Yasamato committed Dec 9, 2024
1 parent 2056212 commit 7db6fd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ export const authOptions: NextAuthConfig = {
brandColor: '#0d6efd',
logo: process.env.NEXT_PUBLIC_DOMAIN + '/icons/logo.png',
},
session: { strategy: "jwt" },
callbacks: {
// we want to access the user id
async session({ session, user }) {
if (user) {
const id = user.id.toString()
session.user.uid = id

const userData = (await findOneTyped(Types.user, id)) as User
const userData = (await findOneTyped(Types.user, id)) as User | null
// create user account if not found
if (userData === null) {
console.log(
Expand All @@ -46,7 +45,7 @@ export const authOptions: NextAuthConfig = {

session.user.accountType = AccountType.user
} else {
session.user.accountType = userData.accountType
session.user.accountType = userData.accountType ?? AccountType.user
}
} else {
console.warn('session call with no user provided')
Expand Down
3 changes: 2 additions & 1 deletion components/buttons/LoginOrOutButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isLogin } from '../../lib/session'
import { signIn, signOut, useSession } from 'next-auth/react'
import { useSession } from 'next-auth/react'
import { signIn, signOut } from '../../auth'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { FC } from 'react'
import { faSignInAlt } from '@fortawesome/free-solid-svg-icons/faSignInAlt'
Expand Down

0 comments on commit 7db6fd7

Please sign in to comment.