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
service cloud.firestore { | |
match /databases/{database}/documents { | |
// Generic method that checks if the email of the currently authenticated user is contained in the admin collection | |
function isAdmin() { | |
return request.auth != null | |
&& get(/databases/$(database)/documents/admins/adminList).data[request.auth.token.email] == true | |
&& request.auth.token.email_verified == true; | |
} | |
// The admin collection is in read only for the admins |
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
// Collection 'admins' | |
{ | |
adminList: { | |
[email protected]: true, | |
[email protected]: true | |
} | |
} | |
// Collection 'planets' | |
{ |
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
// Mount method of my CountDown component | |
mounted() { | |
firestore.collection("admins").get('adminList') | |
.then(()=>{ | |
// console.debug('Admin Loggued :)'); | |
}) | |
.catch((error) =>{ | |
// eslint-disable-next-line no-console | |
console.error(error); | |
this.$router.push('/') |
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
const secureRoute = (to, from, next) => { | |
const currentRoute = to.path; | |
if (from.path === '/wait') { | |
next(); | |
}else { | |
next('/wait'); | |
firebase.auth().onAuthStateChanged((user) => { | |
if(user) { | |
next(currentRoute); | |
} else { |
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
{ | |
"name": "countdowndevfest2018", | |
"version": "1.0.0", | |
"description": "CountDown game for DevFest Nantes 2018", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"vue": "vue", | |
"serve": "vue-cli-service serve", | |
"clean": "del-cli dist/*", | |
"build": "npm run clean && vue-cli-service build && npm run cp-assets", |
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
function updateTree(userId, drawId, result) { | |
return new Promise((resolve, reject) => { | |
admin.database().ref(`/drawUpload/${drawId}`).once('value', (snapshot) => { | |
try { | |
// prepare to update the tree | |
if (snapshot && snapshot.val()) { | |
let snapshotFb = snapshot.val(); | |
// Update the drawing with the classifications | |
snapshotFb.tags = extractTags(result); | |
// Add the drawing in a new part of tree |
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
/** | |
* Method trigger when an image is upload | |
*/ | |
exports.detectImage = functions.storage.object().onChange(event => { | |
const object = event.data; // The Storage object. | |
const fileBucket = object.bucket; // The Storage bucket that contains the file. | |
const filePath = object.name; // File path in the bucket. | |
const contentType = object.contentType; // File content type. | |
const resourceState = object.resourceState; // The resourceState is 'exists' or 'not_exists' (for file/folder deletions). |
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
{ | |
"name": "functions", | |
"description": "Cloud Functions for Firebase", | |
"dependencies": { | |
// Use for the cloud storage | |
"@google-cloud/storage": "^1.4.0", | |
// A wrapper to use child_process in promise | |
"child-process-promise": "^2.2.1", | |
// Use for manipulating the realtime database | |
"firebase-admin": "~5.2.1", |
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
'use strict' | |
/** | |
* Class for playing video | |
* | |
*/ | |
export class VideoPlayer { | |
constructor(parentElt, callBackEnd) { | |
this.videoElt = document.createElement('video'); | |
parentElt.appendChild(this.videoElt); |
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
'use strict' | |
import { | |
PLAYLIST | |
} from './playlist.js'; | |
/** | |
* Class for playing music | |
* | |
* We create an invisible audio element and we play music on it | |
*/ |