Skip to content

Commit

Permalink
Fix isWithinExpirationDate() (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper authored Feb 16, 2024
1 parent 8a5d745 commit e1566c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ When resending verification emails, make sure to implement rate limiting based o
Validate the verification code by comparing it against your database and checking the expiration and email. Make sure to invalidate all user sessions.

```ts
import { isWithinExpiration } from "oslo";
import { isWithinExpirationDate } from "oslo";
import type { User } from "lucia";

app.post("/email-verification", async () => {
Expand Down Expand Up @@ -174,7 +174,7 @@ async function verifyVerificationCode(user: User, code: string): Promise<boolean
await db.table("email_verification_code").where("id", "=", code.id).delete();
await db.commit();

if (!isWithinExpiration(databaseCode.expires_at)) {
if (!isWithinExpirationDate(databaseCode.expires_at)) {
return false;
}
if (databaseCode.email !== user.email) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ When resending verification emails, make sure to implement rate limiting based o
Extract the email verification token from the URL and validate by checking the expiration date and email. If the token is valid, invalidate all existing user sessions and create a new session. Make sure to invalidate all user sessions.

```ts
import { isWithinExpiration } from "oslo";
import { isWithinExpirationDate } from "oslo";

app.get("email-verification/:token", async () => {
// ...
Expand All @@ -131,7 +131,7 @@ app.get("email-verification/:token", async () => {
}
await db.commit();

if (!token || !isWithinExpiration(token.expires_at)) {
if (!token || !isWithinExpirationDate(token.expires_at)) {
return new Response(null, {
status: 400
});
Expand Down

0 comments on commit e1566c0

Please sign in to comment.