Skip to content

Commit fe58f03

Browse files
fix(next): remove console.error from next auth functions (#12881)
### What? Removes the console.error() statement when there is a login error. ### Why? IMO, Libraries should not pollute the console with log statements in all but the most exceptional cases. This prevents users of the library from controlling what goes to standard out. For example, if I want to use structured logging, this log line breaks it. It would be a little better if this console.error() only executed on unexpected errors, but it executes even when a user puts the wrong email / password, so it gets printed relatively frequently. I think you can just remove the logging and let the user of this function catch the error and log as they see fit. --------- Co-authored-by: Jacob Fletcher <[email protected]>
1 parent c7dc1b4 commit fe58f03

File tree

3 files changed

+0
-3
lines changed

3 files changed

+0
-3
lines changed

packages/next/src/auth/login.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export async function login({ collection, config, email, password, username }: L
8181

8282
return result
8383
} catch (e) {
84-
console.error('Login error:', e)
8584
throw new Error(`${e}`)
8685
}
8786
}

packages/next/src/auth/logout.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export async function logout({ config }: { config: any }) {
2323
return { message: 'User logged out successfully', success: true }
2424
}
2525
} catch (e) {
26-
console.error('Logout error:', e)
2726
throw new Error(`${e}`)
2827
}
2928
}

packages/next/src/auth/refresh.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export async function refresh({ collection, config }: { collection: CollectionSl
3636

3737
return { message: 'Token refreshed successfully', success: true }
3838
} catch (e) {
39-
console.error('Refresh error:', e)
4039
throw new Error(`${e}`)
4140
}
4241
}

0 commit comments

Comments
 (0)