feat: improve structure and error handling
This commit is contained in:
69
auth.ts
69
auth.ts
@@ -35,7 +35,6 @@ const customProvider = {
|
||||
},
|
||||
|
||||
profile(profile) {
|
||||
console.log({ profile })
|
||||
return {
|
||||
id: profile.id,
|
||||
sub: profile.sub,
|
||||
@@ -54,17 +53,9 @@ export const config = {
|
||||
},
|
||||
callbacks: {
|
||||
async signIn() {
|
||||
console.log("****** SIGN IN *******")
|
||||
console.log(arguments)
|
||||
console.log("****** END - SIGN IN *******")
|
||||
return true
|
||||
},
|
||||
async session({ session, token, user }) {
|
||||
console.log("****** SESSION *******")
|
||||
console.log({ session })
|
||||
console.log({ token })
|
||||
console.log({ user })
|
||||
console.log("****** END - SESSION *******")
|
||||
if (session.user) {
|
||||
return {
|
||||
...session,
|
||||
@@ -79,7 +70,6 @@ export const config = {
|
||||
return session
|
||||
},
|
||||
async redirect({ baseUrl, url }) {
|
||||
console.log({ redirect_baseUrl: baseUrl, redirect_url: url })
|
||||
if (url.startsWith("/")) {
|
||||
// Allows relative callback URLs
|
||||
return `${baseUrl}${url}`
|
||||
@@ -103,16 +93,9 @@ export const config = {
|
||||
return baseUrl
|
||||
},
|
||||
async authorized({ auth, request }) {
|
||||
console.log("****** AUTHORIZED *******")
|
||||
console.log({ auth })
|
||||
console.log({ request })
|
||||
console.log("****** END - AUTHORIZED *******")
|
||||
return true
|
||||
},
|
||||
async jwt({ session, token, trigger, account }) {
|
||||
console.log("****** JWT *******")
|
||||
console.log({ session, token, trigger, account })
|
||||
console.log("****** END - JWT *******")
|
||||
if (account) {
|
||||
return {
|
||||
access_token: account.access_token,
|
||||
@@ -121,32 +104,32 @@ export const config = {
|
||||
return token
|
||||
},
|
||||
},
|
||||
events: {
|
||||
async signIn() {
|
||||
console.log("#### SIGNIN EVENT ARGS ######")
|
||||
console.log(arguments)
|
||||
console.log("#### END - SIGNIN EVENT ARGS ######")
|
||||
},
|
||||
async session() {
|
||||
console.log("#### SESSION EVENT ARGS ######")
|
||||
console.log(arguments)
|
||||
console.log("#### END - SESSION EVENT ARGS ######")
|
||||
},
|
||||
},
|
||||
logger: {
|
||||
error(code, ...message) {
|
||||
console.info("ERROR LOGGER")
|
||||
console.error(code, message)
|
||||
},
|
||||
warn(code, ...message) {
|
||||
console.info("WARN LOGGER")
|
||||
console.warn(code, message)
|
||||
},
|
||||
debug(code, ...message) {
|
||||
console.info("DEBUG LOGGER")
|
||||
console.debug(code, message)
|
||||
},
|
||||
},
|
||||
// events: {
|
||||
// async signIn() {
|
||||
// console.log("#### SIGNIN EVENT ARGS ######")
|
||||
// console.log(arguments)
|
||||
// console.log("#### END - SIGNIN EVENT ARGS ######")
|
||||
// },
|
||||
// async session() {
|
||||
// console.log("#### SESSION EVENT ARGS ######")
|
||||
// console.log(arguments)
|
||||
// console.log("#### END - SESSION EVENT ARGS ######")
|
||||
// },
|
||||
// },
|
||||
// logger: {
|
||||
// error(code, ...message) {
|
||||
// console.info("ERROR LOGGER")
|
||||
// console.error(code, message)
|
||||
// },
|
||||
// warn(code, ...message) {
|
||||
// console.info("WARN LOGGER")
|
||||
// console.warn(code, message)
|
||||
// },
|
||||
// debug(code, ...message) {
|
||||
// console.info("DEBUG LOGGER")
|
||||
// console.debug(code, message)
|
||||
// },
|
||||
// },
|
||||
} satisfies NextAuthConfig
|
||||
|
||||
export const {
|
||||
|
||||
Reference in New Issue
Block a user