Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fixes]#[1151] #1174

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
"on":
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_CODELABZ_GSOC24 }}"
channelId: live
projectId: codelabz-gsoc24
17 changes: 17 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
"on": pull_request
jobs:
build_and_preview:
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_CODELABZ_GSOC24 }}"
projectId: codelabz-gsoc24
1 change: 1 addition & 0 deletions database.rules.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
"rules": {
".read": false,
".write": false
Expand Down
13 changes: 12 additions & 1 deletion firestore.rules
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
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 true;
allow read, write: if request.time < timestamp.date(2024, 3, 4);
}
}
}
25 changes: 25 additions & 0 deletions functions/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
env: {
es6: true,
node: true
},
parserOptions: {
ecmaVersion: 2018
},
extends: ["eslint:recommended", "google"],
rules: {
"no-restricted-globals": ["error", "name", "length"],
"prefer-arrow-callback": "error",
quotes: ["error", "double", { allowTemplateLiterals: true }]
},
overrides: [
{
files: ["**/*.spec.*"],
env: {
mocha: true
},
rules: {}
}
],
globals: {}
};
3 changes: 1 addition & 2 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules/
private/
node_modules/
59 changes: 14 additions & 45 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,19 @@
const functions = require("firebase-functions");
const dotenv = require("dotenv");
dotenv.config({
path: "../.env"
});

/**
* +++++++++++++++++++CLOUD FUNCTIONS+++++++++++++++++++++++++++++
*/

/**Import functions
* Import function triggers from their respective submodules:
*
* const {onCall} = require("firebase-functions/v2/https");
* const {onDocumentWritten} = require("firebase-functions/v2/firestore");
*
* See a full list of supported triggers at https://firebase.google.com/docs/functions
*/
const onCallFunctions = require("./cloud_functions/onCallFunctions");
const onCreateFunctions = require("./cloud_functions/onCreateFunctions");
const onWriteFunctions = require("./cloud_functions/onWriteFunctions");
const onUpdateFunctions = require("./cloud_functions/onUpdateFunctions");
const pubSubFunctions = require("./cloud_functions/pubSubFunctions");

//+++++++++++++++++++++onCall Functions+++++++++++++++++++++++++++++++++
exports.resendVerificationEmail = functions.https.onCall(
onCallFunctions.resendVerificationEmailHandler
);

exports.sendPasswordUpdateEmail = functions.https.onCall(
onCallFunctions.sendPasswordUpdateEmailHandler
);

//+++++++++++++++++++++onCreate Functions+++++++++++++++++++++++++++++++
exports.sendVerificationEmail = functions.auth
.user()
.onCreate(onCreateFunctions.sendVerificationEmailHandler);

exports.createOrganization = functions.firestore
.document("cl_org_general/{org_handle}")
.onCreate(onCreateFunctions.createOrganizationHandler);

//++++++++++++++++++++onWrite Functions+++++++++++++++++++++++++++++++
exports.registerUserHandle = functions.firestore
.document("cl_user/{uid}")
.onWrite(onWriteFunctions.registerUserHandleHandler);
const { onRequest } = require("firebase-functions/v2/https");
const logger = require("firebase-functions/logger");

//++++++++++++++++++++onUpdate Functions++++++++++++++++++++++++++++++
exports.updateOrgUser = functions.firestore
.document("cl_org_general/{org_handle}/cl_org_users/users")
.onUpdate(onUpdateFunctions.addOrgUserHandler);
// Create and deploy your first functions
// https://firebase.google.com/docs/functions/get-started

//++++++++++++++++++++Pub/Sub Functions++++++++++++++++++++++++++++++
exports.deleteTutorialSteps = functions.pubsub
.schedule("every 7 days")
.onRun(pubSubFunctions.deleteTutorialStepsHandler);
// exports.helloWorld = onRequest((request, response) => {
// logger.info("Hello logs!", {structuredData: true});
// response.send("Hello from Firebase!");
// });
15 changes: 7 additions & 8 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
"logs": "firebase functions:log"
},
"engines": {
"node": "10"
"node": "18"
},
"main": "index.js",
"dependencies": {
"dotenv": "^16.0.1",
"firebase-admin": "^9.0.0",
"firebase-functions": "^3.9.0",
"lodash": "^4.17.19"
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.2.0"
"eslint": "^8.15.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^3.1.0"
},
"private": true
}
13 changes: 13 additions & 0 deletions functions/private/cl-dev-pk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "service_account",
"project_id": "codelabz-gsoc24",
"private_key_id": "f6aec9fe78ebf53b5f6086cdbd09e245f6c0cd22",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCexj7GEzOAbBBJ\nSamCs16P0+CZuzoOir3O1a4GCE2/dGwf7E6YNKzvSqJYexS0FNJwjol16vVx0jUt\n+NJS9kpkTPf3ds4p++5DAy46rom61ktMYz/YZvWTnkke+0+oR50+L8VZrtn8rW2m\n5vhX8uZcx/Mj1+sVC4xMQPPrUwFDTHEkahKkYsnhSmStwHsOGG/KaeKttnTUN0OX\nJSwCtIfHWiKc2eWskgoYeI6V4JHhgp7/G3DJjZAtTMbS8dyXlYuTGMb8upkYSZu5\n8i7sSQcOKmUXU3/ddnlwYX7nmg1NhOmBg0pUSrS4jmagqGjis9N2TrBjzDX1U2I1\ntWQBhICHAgMBAAECggEAAoVJarq3wNG9fOVCfB2aN5uqZn9J/gA4izQUzBSb49I6\nPFPzopYTf+HtOeJhdN/FFbqYPdsBEoppkiqab8JL5AykxO3fQc4K/WuWLEzEno3X\nf76DoPfhe4ix/5jOrgzN5WERN61/Z5Bs2FZftoItI2eAWZDhwTbjf1CjVdGFwWNK\n3dlMlVauDvbMKZABan8bjsLTVAox95hXVuqWrqVtheHwpT+hmXgcmdeOx9DlSPSs\nDHEYnlh6O6gxY9RiQ7LAjws68eO9GxCZDkfvM3Ok/g6SIswrgWL2yTBq8SPKDcwM\nNs2Aulb9jnYsC324u5vBS1UXw6Y0xdyn2pxwtGrqoQKBgQDbI33z0u18lA2ZPx6G\nPqHUdW62i+vbCHLWYB6fCha7t39ZhieVpuVvfcN2XmLiPmFUJqMbxuSEn7qK3DcP\n+g/wEAvbouCm2oB+LQkE4WR7j1Uam+hQYN7s2yxXcqiX4VW3wgIpYY1XNnHqZkup\n8yGSu0mfXR67uGMvdBLVIFRz1QKBgQC5e1vwWXVXSTMO7Ml3T7ea30aM+LyMA6Bi\nBlNcqRaXvcB3DalNBHzabKFB7P2UR8ZH1nBOliEVeKJhP4+itlBl0GqVq1EP88VC\nIdPNreWjdoUyFlqnLOu1xaEOJAEve4YS+V5AJzCmozQJNvmdeVkOitzv0XvV+Flp\nuUBqlNd86wKBgDmJJQ26iL4XxUZCK0qF8UluF8Z4EFHu8u/URtXs+TEKKbagoY4K\nRt0yAPr4JzBNvpIwnsyxONiVc4336cEZH8wg+mwNZLyKTAhU3LRaVV6XsHmPC7zm\n4kD//rFrGlbeQ/o+RwEEau7GDbzEZQNXIa573AWqlmIlNG2GJVet6F6NAoGBAKXv\nDDMbdPRfkgP6JcpNUM6GjNE0/UitPeA0FIPC6Wla4kIfwKQcLa4inKkj4T+0blh6\nKQLFIFfbEjm56UABpi9Pouq+1shUptYg+SD6P4RbVZGXmgYRE9YMNac24rCd6zYy\nTPVLmiSZwMW1nt4YX2m5JSqO2CB2C1ef2VcATT99AoGAT/nNCZN8C+gu1gJ6mkmq\nJDgNdLV907vKenZlOez5EB6Uns20v1YyOuK7EyMUnf9NHr/5ZyPw+yT7RCJ28YO3\nclXF4gkKuVwcxm/ccsZhmqBb2EzrF1rnbcgtEocRG3zYmPhFZdqeHLQ9/GSneC8Q\neAxgoA/wdxA/piq5GTpiFKg=\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-45w7y@codelabz-gsoc24.iam.gserviceaccount.com",
"client_id": "112002644236744622520",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-45w7y%40codelabz-gsoc24.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
114 changes: 81 additions & 33 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,89 @@
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/cl_logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome to Firebase Hosting</title>

<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
<!-- update the version number as needed -->
<script defer src="/__/firebase/10.8.0/firebase-app-compat.js"></script>
<!-- include only the Firebase features as you need -->
<script defer src="/__/firebase/10.8.0/firebase-auth-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-database-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-firestore-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-functions-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-messaging-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-storage-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-analytics-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-remote-config-compat.js"></script>
<script defer src="/__/firebase/10.8.0/firebase-performance-compat.js"></script>
<!--
initialize the SDK after all desired features are loaded, set useEmulator to false
to avoid connecting the SDK to running emulators.
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>CodeLabz</title>
<script defer src="/__/firebase/init.js?useEmulator=true"></script>

<style media="screen">
body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; }
#message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; }
#message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; }
#message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;}
#message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; }
#message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; }
#message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
#load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; }
@media (max-width: 600px) {
body, #message { margin-top: 0; background: white; box-shadow: none; }
body { border-top: 16px solid #ffa100; }
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<div id="message">
<h2>Welcome</h2>
<h1>Firebase Hosting Setup Complete</h1>
<p>You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!</p>
<a target="_blank" href="https://firebase.google.com/docs/hosting/">Open Hosting Documentation</a>
</div>
<p id="load">Firebase SDK Loading&hellip;</p>

<script>
document.addEventListener('DOMContentLoaded', function() {
const loadEl = document.querySelector('#load');
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
// // The Firebase SDK is initialized and available here!
//
// firebase.auth().onAuthStateChanged(user => { });
// firebase.database().ref('/path/to/ref').on('value', snapshot => { });
// firebase.firestore().doc('/foo/bar').get().then(() => { });
// firebase.functions().httpsCallable('yourFunction')().then(() => { });
// firebase.messaging().requestPermission().then(() => { });
// firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { });
// firebase.analytics(); // call to activate
// firebase.analytics().logEvent('tutorial_completed');
// firebase.performance(); // call to activate
//
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

try {
let app = firebase.app();
let features = [
'auth',
'database',
'firestore',
'functions',
'messaging',
'storage',
'analytics',
'remoteConfig',
'performance',
].filter(feature => typeof app[feature] === 'function');
loadEl.textContent = `Firebase SDK loaded with ${features.join(', ')}`;
} catch (e) {
console.error(e);
loadEl.textContent = 'Error loading the Firebase SDK, check the console.';
}
});
</script>
</body>
</html>
Loading