File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,14 @@ const getExistingSubscriptionLicenseByUserId = async (userId: string): Promise<L
7272 return result || null
7373}
7474
75+ const getLicenseByUserId = async ( userId : string ) : Promise < License | null > => {
76+ const result = await db ( tableName )
77+ . where ( { user_id : userId } )
78+ . first ( '*' )
79+
80+ return result || null
81+ }
82+
7583const createLicense = async ( data : CreateLicenseData ) : Promise < License > => {
7684 const [ license ] = await db ( tableName )
7785 . insert ( {
@@ -126,6 +134,7 @@ export const LicenseRepo = {
126134 getActiveLicenseByUserId,
127135 getFreeTrialLicenseByUserId,
128136 getExistingSubscriptionLicenseByUserId,
137+ getLicenseByUserId,
129138 createLicense,
130139 updateLicense,
131140 deleteLicense,
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const getActiveLicense = async (userId: string) => {
66}
77
88const startFreeTrial = async ( userId : string ) => {
9- const existingLicense = await LicenseRepo . getActiveLicenseByUserId ( userId )
9+ const existingLicense = await LicenseRepo . getLicenseByUserId ( userId )
1010 if ( existingLicense ) {
1111 throw new ApiError ( 'User already has a license' , 422 )
1212 }
You can’t perform that action at this time.
0 commit comments