Код: Выделить всё
import admin from "firebase-admin";
import functions from "firebase-functions";
admin.initializeApp();
const db = admin.firestore();
export const createStudentAccount = functions.https.onCall(async (data, context) => {
if (!context.auth) {
// this always throws because context.auth is undefined
throw new functions.https.HttpsError("unauthenticated", "You must be logged in. "
+ JSON.stringify(context)); // just so I can see the value of context from the client side
}
// rest of the code
});
< /code>
Вызов функции: < /p>
import { getFunctions, httpsCallable } from 'firebase/functions';
import { app, auth, db } from './firebase.js';
const functions = getFunctions(app, "us-central1");
export async function registerStudent({ fname, lname, email, oen }) {
console.log(auth);
const fn = httpsCallable(functions, 'createStudentAccount');
const result = await fn({ fname, lname, email, password: oen, isAdmin: false });
return result.data;
}
Код: Выделить всё
console.log(auth)
Подробнее здесь: https://stackoverflow.com/questions/796 ... -is-authen