mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-20 20:26:55 -05:00
fix(api-key): preserve server errors after validation
This commit is contained in:
@@ -197,11 +197,13 @@ Otherwise if it throws, it will throw an `APIError`.
|
||||
|
||||
#### Result
|
||||
|
||||
| Outcome | Behavior |
|
||||
| ------------------------------ | --------------------------------------------------------------------------------------------------------------- |
|
||||
| The key is accepted | Returns `valid: true`, the key details, and `error: null`. |
|
||||
| The key is rejected | Returns `valid: false`, an error describing the rejection, and `key: null`. |
|
||||
| Verification fails to complete | Throws an `APIError`, for example when a database connection fails. Handle this separately from a rejected key. |
|
||||
`valid: true` means the key passed verification. Failures in best-effort storage updates are logged without changing the verification result.
|
||||
|
||||
| Outcome | Behavior |
|
||||
| ------------------------------ | --------------------------------------------------------------------------------------- |
|
||||
| The key is accepted | Returns `valid: true`, the key details, and `error: null`. |
|
||||
| The key is rejected | Returns `valid: false`, an error describing the rejection, and `key: null`. |
|
||||
| Verification fails to complete | Throws an `APIError` when a required verification step fails, such as a storage lookup. |
|
||||
|
||||
```ts
|
||||
type Result = {
|
||||
|
||||
Reference in New Issue
Block a user