我正在应用程序中使用可调用函数来更新用户声明。firebase 函数位于 Typescript 中,并且有一个接口来描述函数所需的数据形状。
我想在客户端做同样的事情,这样团队中的任何开发人员都可以快速找到云函数的需求,而无需查看函数目录中的代码。
Firebase 云功能functions/src/index.ts
:
// This is the required data, that I would like to specify client side
interface GivePermissionsParams {
uid: string;
email: string;
newClaim: Partial<Permissions>;
}
/**
* Callable function to give a user new permissions in the form
* of custom claims and firestore properties
*/
exports.givePermission = functions.https.onCall(
async (data: GivePermissionsParams, context) => {
if (!context.auth?.token.admin) {
throw new HttpsError(
'permission-denied',
`Non admin user ${context.auth?.uid} attempted to update permissions`
);
} …
Run Code Online (Sandbox Code Playgroud) 我定期更新 emulator\xe2\x80\x99s Firestore 数据,使其尽可能接近生产环境。
\n我最近在打开身份验证模拟器的情况下更新了自定义声明逻辑。我的所有用户都无法通过 uid 从 Admin Auth SDK 访问(因为它们在模拟器中是\xe2\x80\x99t)。
\n根据文档更新声明:
\n\ngetAuth()\n .setCustomUserClaims(uid, { admin: true })\n .then(() => {\n // The new custom claims will propagate to the user\'s ID token the\n // next time a new one is issued.\n });\n\n
Run Code Online (Sandbox Code Playgroud)\n我(愚蠢地)通过关闭 Auth Emulator 解决了这个问题,该模拟器在开发和测试时修改了生产用户的自定义声明。
\n有没有办法像 Firestore 一样导出身份验证数据并导入模拟器?
\n或者,
\n在 Auth 模拟器中创建假用户时,有没有办法指定 uid(以匹配 Firestore)?
\n我有一个词法编辑器,需要将其序列化为 html,以便我可以将其嵌入到电子邮件模板中。
我在使用该函数时不断遇到以下错误$generateHtmlFromNodes
:
Error: Unable to find an active editor state.
State helpers or node methods can only be
used synchronously during the callback of editor.update() or editorState.read().
Run Code Online (Sandbox Code Playgroud)
我的编辑器组件采用一个 prop,即 LexicalEditor 类型的 editorRef,这确保我可以从父级访问编辑器,我希望在父级中处理电子邮件的序列化和发送。
编辑器.tsx:
Error: Unable to find an active editor state.
State helpers or node methods can only be
used synchronously during the callback of editor.update() or editorState.read().
Run Code Online (Sandbox Code Playgroud)
我的父组件:
interface EditorProps {
editorRef: React.MutableRefObject<LexicalEditor>;
}
export const Editor = (props: EditorProps) => {
const initialConfig = { …
Run Code Online (Sandbox Code Playgroud) 我想自定义电子邮件模板(使用触发电子邮件扩展模板)以向用户发送验证链接。
据我所知,无法从 Firebase 控制台更改模板,因为它可以防止垃圾邮件。
我知道能够自定义操作电子邮件处理程序(单击验证电子邮件中的链接时用户登陆的页面),以及emailVerified
手动更新身份验证用户属性的能力。
还有一种方法可以生成 firebase 会使用的验证链接吗?具有以下属性的一种:
我理想的解决方案是在使用生成的验证链接注册时向用户发送自定义模板。将用户定向到自定义处理程序页面,并使用文档applyActionCode()
中所示的函数来验证电子邮件(我希望这会隐式更新记录上的属性。)emailVerified
Auth.User
在 Flutter 中使用 HttpsCallable 插件时,我正在努力获取要传递到我的 Cloud Function 的参数。
我的 Cloud Functions 中的日志显示没有传递任何参数。
我的云函数index.js
// acts as an endpoint getter for Python Password Generator FastAPI
exports.getPassword = functions.https.onRequest((req, res) => {
const useSymbols = req.query.useSymbols;
const pwLength = req.query.pwdLength;
// BUILD URL STRING WITH PARAMS
const ROOT_URL = `http://34.72.115.208/password?pwd_length=${pwLength}&use_symbols=${useSymbols}`;
const debug = {
pwLenType: typeof pwLength,
pwLen: pwLength,
useSymbolsType: typeof useSymbols,
useSymbols: useSymbols,
};
console.log(req.query);
console.log(debug);
// let password: any; // password to be received
cors(req, res, () => { …
Run Code Online (Sandbox Code Playgroud)