firebase-admin

How to verify users current password?

落花浮王杯 提交于 2019-12-22 04:08:18
问题 So, maybe I missed this somewhere in the docs but I couldn't find anything of the sort. I wan't my users to have to type in their current password to be able to create a new one. From what I understand if the user is authenticated he is able to update his password without providing his current one. Even if this might be somewhat secure I would rather have him type his old one to prevent people from going on already authenticated sessions from say family members or so and changing the pw. Is

nodejs firebase error RangeError: Maximum call stack size exceeded failure

半世苍凉 提交于 2019-12-22 03:44:50
问题 I have an error from the firebase : FIREBASE WARNING: Exception was thrown by user callback. RangeError: Maximum call stack size exceeded I didn't find my mistake. I'm very lost in here, please help. My code looks like this: app.post('/updateCoords', (req, res)=>{ var usrID = req.body.id; var usrCoords = { lat: req.body.lat, long: req.body.long } console.log('userID : '+usrID+' lat : '+usrCoords.lat+' long : '+usrCoords.long); var ref = database.ref('users'); try{ ref.orderByChild('username')

Firestore delete all user data on account delete using a Firebase Function

Deadly 提交于 2019-12-21 22:35:31
问题 I'm new to Firebase/Firestore and trying to create a Firebase Function that will delete all user data upon deletion of an Auth account. My functions is successfully called on deleting an account and I'm trying to delete a collection called links for that user and then delete the user document. But I'm getting an error of linksRef.forEach is not a function. Any guidance on how I'd do this cascading delete? exports.deleteUserData = functions.auth.user().onDelete((event) => { const userId =

Google Firebase: Get, update or create documents using Python

六月ゝ 毕业季﹏ 提交于 2019-12-21 21:42:59
问题 I am not able to get, update or create the documents in Google Firebase (Cloud Firestore) database using Python. What I have: A) The database with a collection and documents (inserted manually on the web): B) Credential JSON file saved as test.json (it is called often path/to/serviceKey.json in the documentation), which looks like this (redacted): { "type": "service_account", "project_id": "test-6f02d", "private_key_id": "fffca ... 5b7", "private_key": "-----BEGIN PRIVATE KEY-----\n ... 1IHE=

Firebase REST auth when creating token with node.js admin sdk

眉间皱痕 提交于 2019-12-20 10:45:07
问题 I know this issue was asked a lot here, but I still cannot seem to find the exact answer that can solve my problem. I wish to access Firebase using REST calls, by adding an access_token param. The access_token is created using the Node.js Admin SDK, using the following code: var admin = require("firebase-admin"); var serviceAccount = require("./pk.json"); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: "https://XXX.firebaseio.com" }); var uid = "1234";

Is there a way to add security rules that apply to admin in Firebase?

北慕城南 提交于 2019-12-20 03:14:16
问题 Does anyone know how to enforce security rules in Firebase on writes performed by the admin server? E.g.: userDetail: { ".validate" : //some security rule based on database reference// } I want to ensure that a write by admin server adheres to this validation rule. I understand that a security rule can be put in place on the server itself, but I want to ensure that the data is consistent with another location in the database that can be modified by other server instances. 回答1: You cannot

Get Public URL from file uploaded with firebase-admin

元气小坏坏 提交于 2019-12-20 01:39:11
问题 I use firebase-admin and firebase-functions to upload a file in Firebase Storage. I have this rules in storage: service firebase.storage { match /b/{bucket}/o { match /images { allow read; allow write: if false; } } } And I want get a public URL with this code: const config = functions.config().firebase; const firebase = admin.initializeApp(config); const bucketRef = firebase.storage(); server.post('/upload', async (req, res) => { // UPLOAD FILE await stream.on('finish', async () => { const

Verifying firebase custom token to get token ID fails when using jsonwebtoken

大憨熊 提交于 2019-12-19 14:44:35
问题 On the backend a custom token is generated via firebase's admin SDK thusly: router.use('/get-token', (req, res) => { var uid = "big-secret"; admin.auth().createCustomToken(uid) .then(function(customToken) { res.json({ instanceID: customToken }); }) .catch(function(error) { console.log("Error creating custom token:", error); }); }); The client frontend app then picks up the customToken and with it makes a request back to the backend to verify: const fbPrivateKey = serviceAccount.private_key;

Firestore moving to timestamps in Firebase functions

筅森魡賤 提交于 2019-12-18 12:27:13
问题 Yesterday, all my firebase functions started throwing the following warning: The behavior for Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK. To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods: const firestore = new Firestore(); const settings = {/* your settings... */ timestampsInSnapshots: true}; firestore.settings(settings); With this change, timestamps stored

Is there a way to send the verification email with the Firebase Admin SDK from my Node.js server?

百般思念 提交于 2019-12-18 06:06:32
问题 Is there a way to send the email verification email from my server ? This is how it's done on the client: authData.sendEmailVerification().then(function() { Is there a way to do it on the server ? 回答1: firebaser here To my surprise there currently is no option to send verification email from within the Admin SDK. I'd recommend you file a feature request. What you can do from the Admin SDK is update a user profile to mark their email as verified. This allows you to take control of the entire