Skip to content

Commit

Permalink
Merge pull request #134 from giselles-ai/re-prevent-redirection-free-…
Browse files Browse the repository at this point in the history
…users

Skip checking subscription if freePlanFlag is enabled
  • Loading branch information
satococoa authored Nov 29, 2024
2 parents b1c0be7 + 2f28058 commit 590e5ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { retrieveActiveStripeSubscriptionBySupabaseUserId } from "@/services/accounts/actions";
import { NextResponse } from "next/server";
import { freePlanFlag } from "./flags";
import { supabaseMiddleware } from "./lib/supabase";
import { isEmailFromRoute06 } from "./lib/utils";

Expand All @@ -11,6 +12,12 @@ export default supabaseMiddleware(async (user, request) => {
return NextResponse.redirect(url);
}

// Users can use giselle without subscription if the free plan is enabled
const freePlanEnabled = await freePlanFlag();
if (freePlanEnabled) {
return;
}

// Proceeding to check the user's subscription status since the email is not from the route06.co.jp
if (!isEmailFromRoute06(user.email ?? "")) {
const subscription = await retrieveActiveStripeSubscriptionBySupabaseUserId(
Expand Down

0 comments on commit 590e5ce

Please sign in to comment.