-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from codelitdev:rajat1saxena/issue135
Bug: User creating script for self hosting is failing
- Loading branch information
Showing
6 changed files
with
12 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
import { getPlan } from "../plan/queries"; | ||
import { Subscription } from "./model"; | ||
import { getSubscription } from "./queries"; | ||
import { getUser } from "../user/queries"; | ||
|
||
export async function validateSubscription(userId: string) { | ||
const subscription: Subscription | null = await getSubscription(userId); | ||
const validSubscription = | ||
subscription && isSubscriptionValid(subscription.endsAt); | ||
if (!validSubscription) { | ||
return false; | ||
} | ||
|
||
const plan = await getPlan(subscription!.planId.toString()); | ||
if (!plan) { | ||
return false; | ||
} | ||
|
||
return true; | ||
const user = await getUser(userId); | ||
return user && isDateInFuture(user.subscriptionEndsAfter); | ||
} | ||
|
||
function isSubscriptionValid(dateStr: Date): boolean { | ||
function isDateInFuture(dateStr: Date): boolean { | ||
return new Date(dateStr).getTime() > new Date().getTime(); | ||
} |