mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-23 23:02:17 +10:00
fix(auth): allow unlinking providers after the session ages past a day (#3364)
Better Auth guards `/unlink-account` with `freshSessionMiddleware`, which
rejects any session whose `createdAt` is older than `freshAge` (one day by
default). Sessions here last a week and there is no re-authentication flow to
refresh that timestamp, so disconnecting a provider failed with
`SESSION_NOT_FRESH` for every user who signed in more than a day ago.
Disable the freshness gate, and teach `getReadableErrorMessage` to read plain
error objects: Better Auth client errors are `{ code, message, status }`
objects rather than `Error` instances, so every auth toast was collapsing to
its generic fallback instead of showing the real reason.
This commit is contained in:
@@ -13,3 +13,9 @@ describe("social provider signup policy", () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("session freshness", () => {
|
||||
it("disables the freshness gate so provider unlinking works for week-old sessions", () => {
|
||||
expect(auth.options.session?.freshAge).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -203,6 +203,12 @@ const getAuthConfig = () => {
|
||||
},
|
||||
},
|
||||
|
||||
// Better Auth gates `/unlink-account` (and `/list-sessions`) behind a "fresh"
|
||||
// session, which defaults to one day old. Sessions here live for a week and
|
||||
// there is no re-authentication flow to refresh that timestamp, so disconnecting
|
||||
// a provider failed with `SESSION_NOT_FRESH` for anyone who signed in yesterday.
|
||||
session: { freshAge: 0 },
|
||||
|
||||
account: {
|
||||
accountLinking: {
|
||||
enabled: true,
|
||||
|
||||
Reference in New Issue
Block a user