From 08f1243729a3a930406af3bb76b33751f214585e Mon Sep 17 00:00:00 2001 From: DhanshCOSQ Date: Sat, 12 Apr 2025 03:23:13 +0000 Subject: [PATCH 1/3] feature/fitlien-add-cors (#15) Reviewed-on: https://git.cosqnet.com/cosqnet/fitlien-services/pulls/15 Co-authored-by: DhanshCOSQ Co-committed-by: DhanshCOSQ --- functions/src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index 05ae00a..045a927 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -384,7 +384,8 @@ export const createCashfreeOrder = onRequest({ productInfo, userId, gymId, - orderId + orderId, + webHostUrl, } = request.body; if (!amount || !customerEmail || !customerPhone) { @@ -422,7 +423,7 @@ export const createCashfreeOrder = onRequest({ customer_phone: customerPhone }, order_meta: { - return_url: `https://${process.env.FITLIENHOST}/payment-bridge?order_id=${orderId}&hash_key=${hashKey}&user_id=${userId}&gym_id=${gymId}`, + return_url: `https://fitlien.com/payment-bridge?order_id=${orderId}&hash_key=${hashKey}&user_id=${userId}&gym_id=${gymId}&web_host_url=${webHostUrl}`, // notify_url: `https://$filien.web.app/verifyCashfreePayment` }, order_note: productInfo || 'Fitlien Membership' From a9e4b31eb99615d60d20dcc1221a90ef86d0aff0 Mon Sep 17 00:00:00 2001 From: aswincosq Date: Sun, 13 Apr 2025 11:46:50 +0530 Subject: [PATCH 2/3] Updated return url. --- functions/package-lock.json | 5 +++++ functions/package.json | 1 + functions/src/index.ts | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/package-lock.json b/functions/package-lock.json index 8a295b3..fc5ea89 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -14,6 +14,7 @@ "firebase-admin": "^12.6.0", "firebase-functions": "^6.0.1", "form-data": "^4.0.1", + "functions": "file:", "html-to-text": "^9.0.5", "long": "^4.0.0", "mailgun.js": "^10.4.0", @@ -3084,6 +3085,10 @@ "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "optional": true }, + "node_modules/functions": { + "resolved": "", + "link": true + }, "node_modules/gaxios": { "version": "6.7.1", "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.7.1.tgz", diff --git a/functions/package.json b/functions/package.json index 939628c..f593fbc 100644 --- a/functions/package.json +++ b/functions/package.json @@ -21,6 +21,7 @@ "firebase-admin": "^12.6.0", "firebase-functions": "^6.0.1", "form-data": "^4.0.1", + "functions": "file:", "html-to-text": "^9.0.5", "long": "^4.0.0", "mailgun.js": "^10.4.0", diff --git a/functions/src/index.ts b/functions/src/index.ts index 045a927..4dce3c8 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -423,8 +423,7 @@ export const createCashfreeOrder = onRequest({ customer_phone: customerPhone }, order_meta: { - return_url: `https://fitlien.com/payment-bridge?order_id=${orderId}&hash_key=${hashKey}&user_id=${userId}&gym_id=${gymId}&web_host_url=${webHostUrl}`, - // notify_url: `https://$filien.web.app/verifyCashfreePayment` + return_url: `http://${webHostUrl}/?order_id=${orderId}&hash_key=${hashKey}&user_id=${userId}&gym_id=${gymId}#/payment-status-screen`, }, order_note: productInfo || 'Fitlien Membership' }, From 7a346f62a8297bbf8c35df8b1aadb1c801040a71 Mon Sep 17 00:00:00 2001 From: Benoy Bose Date: Sun, 13 Apr 2025 13:29:36 +0530 Subject: [PATCH 3/3] Updated firestore rules and index --- .firebaserc | 5 +- firebase.json | 3 +- firestore.indexes.json | 166 +++++++++++++++++++++++++++++++++++++++++ firestore.rules | 21 +++--- 4 files changed, 179 insertions(+), 16 deletions(-) diff --git a/.firebaserc b/.firebaserc index 74dd134..7ea5cba 100644 --- a/.firebaserc +++ b/.firebaserc @@ -2,6 +2,7 @@ "projects": { "debug": "fitlien-dev", "qa": "fitlien-qa", - "release": "fitlien" + "release": "fitlien", + "default": "fitlien-dev" } -} \ No newline at end of file +} diff --git a/firebase.json b/firebase.json index abf2c13..dd93bf2 100644 --- a/firebase.json +++ b/firebase.json @@ -14,8 +14,7 @@ "firebase-debug.*.log", "*.local" ], - "predeploy": [ - ] + "predeploy": [] } ], "storage": { diff --git a/firestore.indexes.json b/firestore.indexes.json index fe4aa78..de60f82 100644 --- a/firestore.indexes.json +++ b/firestore.indexes.json @@ -1,5 +1,33 @@ { "indexes": [ + { + "collectionGroup": "day_pass_bookings", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "userId", + "order": "ASCENDING" + }, + { + "fieldPath": "createdAt", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "day_pass_entries", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "bookingId", + "order": "ASCENDING" + }, + { + "fieldPath": "entryDate", + "order": "ASCENDING" + } + ] + }, { "collectionGroup": "gyms", "queryScope": "COLLECTION_GROUP", @@ -13,6 +41,144 @@ "order": "ASCENDING" } ] + }, + { + "collectionGroup": "gyms", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "userId", + "order": "ASCENDING" + }, + { + "fieldPath": "name", + "order": "ASCENDING" + } + ] + }, + { + "collectionGroup": "memberships", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "gymId", + "order": "ASCENDING" + }, + { + "fieldPath": "createdAt", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "notifications", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "clientId", + "order": "ASCENDING" + }, + { + "fieldPath": "timestamp", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "notifications", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "clientId", + "order": "ASCENDING" + }, + { + "fieldPath": "type", + "order": "ASCENDING" + }, + { + "fieldPath": "timestamp", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "notifications", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "ownerId", + "order": "ASCENDING" + }, + { + "fieldPath": "timestamp", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "notifications", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "ownerId", + "order": "ASCENDING" + }, + { + "fieldPath": "type", + "order": "ASCENDING" + }, + { + "fieldPath": "timestamp", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "notifications", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "trainerId", + "order": "ASCENDING" + }, + { + "fieldPath": "timestamp", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "notifications", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "type", + "order": "ASCENDING" + }, + { + "fieldPath": "userId", + "order": "ASCENDING" + }, + { + "fieldPath": "timestamp", + "order": "DESCENDING" + } + ] + }, + { + "collectionGroup": "termsandconditions", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "normalizedName", + "order": "ASCENDING" + }, + { + "fieldPath": "userUid", + "order": "ASCENDING" + } + ] } ], "fieldOverrides": [] diff --git a/firestore.rules b/firestore.rules index cf50f51..03eee86 100644 --- a/firestore.rules +++ b/firestore.rules @@ -1,19 +1,16 @@ rules_version = '2'; - service cloud.firestore { match /databases/{database}/documents { - - // This rule allows anyone with your Firestore database reference to view, edit, - // and delete all data in your Firestore database. It is useful for getting - // started, but it is configured to expire after 30 days because it - // leaves your app open to attackers. At that time, all client - // requests to your Firestore database will be denied. - // - // Make sure to write security rules for your app before that time, or else - // all client requests to your Firestore database will be denied until you Update - // your rules match /{document=**} { - allow read, write: if request.time < timestamp.date(2025, 1, 10); + allow read, write: if request.auth != null; + } + match /day_pass_bookings/{bookingId} { + allow read: if true; + allow write: if request.auth != null; + } + match /gyms/{gymId} { + allow read: if true; + allow write: if request.auth != null; } } } \ No newline at end of file