From 748c01044c4ed209dd1e632d3a62bfe73e433723 Mon Sep 17 00:00:00 2001 From: aswincosq Date: Mon, 14 Apr 2025 04:10:18 +0530 Subject: [PATCH 1/2] Fixed function --- functions/src/index.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index 4dce3c8..e5564d6 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -402,15 +402,14 @@ export const createCashfreeOrder = onRequest({ return; } - const isTest = true; const hashKey = `hash_${Date.now()}_${uid.substring(0, 1)}_${orderId}`; - const apiUrl = isTest - ? 'https://sandbox.cashfree.com/pg/orders' - : 'https://api.cashfree.com/pg/orders'; + + let apiUrl = process.env.CASHFREE_URL; + try { const cashfreeResponse = await axios.post( - apiUrl, + apiUrl!, { order_id: orderId, hash_key: hashKey, @@ -506,14 +505,11 @@ export const verifyCashfreePayment = onRequest({ const clientId = process.env.CASHFREE_CLIENT_ID; const clientSecret = process.env.CASHFREE_CLIENT_SECRET; - const isTest = process.env.CASHFREE_ENVIRONMENT !== 'production'; - const apiUrl = isTest - ? `https://sandbox.cashfree.com/pg/orders/${orderId}` - : `https://api.cashfree.com/pg/orders/${orderId}`; + const apiUrl = process.env.CASHFREE_URL; const cashfreeResponse = await axios.get( - apiUrl, + apiUrl!, { headers: { 'x-api-version': '2022-09-01', -- 2.43.0 From 6d1d175ca9fc32556368db795924ec5ad233d55d Mon Sep 17 00:00:00 2001 From: aswincosq Date: Mon, 14 Apr 2025 04:11:24 +0530 Subject: [PATCH 2/2] Squashed commit of the following: commit 9f259de4f674851b380f5d87d40a4ff0fe6600f5 Merge: dc91c12 fcd5f5d Author: Benoy Bose Date: Mon Apr 14 00:11:12 2025 +0530 Merge branch 'dev' of cosqnet.com:cosqnet/fitlien-services into dev commit dc91c123bb8db963417b97f2f71e45e6f5bb399d Author: Benoy Bose Date: Mon Apr 14 00:11:09 2025 +0530 Updated bucket permissions commit fcd5f5db4740542df8c5170722ce8f9e665a4cf7 Author: DhanshCOSQ Date: Sun Apr 13 10:07:51 2025 +0000 feature/fitlien-add-cors (#18) Reviewed-on: https://git.cosqnet.com/cosqnet/fitlien-services/pulls/18 Co-authored-by: DhanshCOSQ Co-committed-by: DhanshCOSQ commit 01c87ffcfa2c8fc5a11186d161902f6fa279dd30 Author: DhanshCOSQ Date: Sun Apr 13 08:19:03 2025 +0000 Changed collection names (#17) Reviewed-on: https://git.cosqnet.com/cosqnet/fitlien-services/pulls/17 Co-authored-by: DhanshCOSQ Co-committed-by: DhanshCOSQ commit 0ecef0c0511ca433c22944d177b376f112a3ff7d Merge: 7a346f6 0944760 Author: Benoy Bose Date: Sun Apr 13 13:29:42 2025 +0530 Merge branch 'dev' of cosqnet.com:cosqnet/fitlien-services into dev commit 7a346f62a8297bbf8c35df8b1aadb1c801040a71 Author: Benoy Bose Date: Sun Apr 13 13:29:36 2025 +0530 Updated firestore rules and index commit 094476072e262a2c13b0300b2b8b9553987a4813 Merge: 08f1243 a9e4b31 Author: Aswin B. S Date: Sun Apr 13 06:19:20 2025 +0000 Merge pull request 'Updated return url.' (#16) from feature/test-deploy into dev Reviewed-on: https://git.cosqnet.com/cosqnet/fitlien-services/pulls/16 --- .firebaserc | 5 +- firebase.json | 3 +- firestore.indexes.json | 168 ++++++++++++++++++++++++++++++++++++++++- firestore.rules | 21 +++--- functions/src/index.ts | 2 +- storage.rules | 7 +- 6 files changed, 183 insertions(+), 23 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..8d0c63f 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,7 +41,145 @@ "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": "terms_and_conditions", + "queryScope": "COLLECTION", + "fields": [ + { + "fieldPath": "normalizedName", + "order": "ASCENDING" + }, + { + "fieldPath": "userUid", + "order": "ASCENDING" + } + ] } ], "fieldOverrides": [] -} +} \ No newline at end of file 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 diff --git a/functions/src/index.ts b/functions/src/index.ts index e5564d6..31300e9 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -422,7 +422,7 @@ export const createCashfreeOrder = onRequest({ customer_phone: customerPhone }, order_meta: { - return_url: `http://${webHostUrl}/?order_id=${orderId}&hash_key=${hashKey}&user_id=${userId}&gym_id=${gymId}#/payment-status-screen`, + return_url: `http://${webHostUrl}?order_id=${orderId}&hash_key=${hashKey}&user_id=${userId}&gym_id=${gymId}#/payment-status-screen`, }, order_note: productInfo || 'Fitlien Membership' }, diff --git a/storage.rules b/storage.rules index f08744f..fbb489a 100644 --- a/storage.rules +++ b/storage.rules @@ -1,12 +1,9 @@ rules_version = '2'; -// Craft rules based on data in your Firestore database -// allow write: if firestore.get( -// /databases/(default)/documents/users/$(request.auth.uid)).data.isAdmin; service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { - allow read, write: if false; + allow read, write: if request.auth != null; } } -} +} \ No newline at end of file -- 2.43.0