Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/nextAuthAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ export default function Adapter() {
},
async useVerificationToken({ identifier, token }) {
const tokenInStore = await (await store).get(identifier);
if (tokenInStore.token === token) {
await (await store).delete(identifier);
// next-auth treats any non null return value as a valid token, so the
// comparison has to decide the return value and not only the deletion.
if (!tokenInStore || tokenInStore.token !== token) {
return null;
}
return tokenInStore ?? null;
await (await store).delete(identifier);
return tokenInStore;
},
};
}