簡體   English   中英

如何在角度項目中包括Firebase管理員

[英]How to include firebase admin in angular project

我想在使用Firebase進行用戶身份驗證的Angular 7項目中添加管理用戶的功能。

我的應用程序已成功使用我項目中用戶的Firebase身份驗證。

現在,我想讓程序的管理員用戶能夠列出用戶,更新用戶,添加用戶,控制用戶角色等。我不希望我的用戶需要訪問firebase管理控制台。

我的第一個測試只是使用admin.auth()。listUsers函數列出Firebase用戶。 關於如何使用node.js做到這一點,有很多很好的文檔,但下一步沒有Angular。

我的問題是需要定義變量“ admin”。

當我使用以下的node.js代碼時:

var admin = require('firebase-admin');

我收到很多錯誤,例如:

找不到./node_modules/google-gax/build/src/operationsClient.js模塊中的錯誤:錯誤:無法解析'/ Users / Stan / Sites / Sites / google / dallas / node_modules / google-gax中的'./operations_client_config' ./node_modules/google-auth-library/build/src/auth/googleauth.js中的/ build / src'錯誤找不到模塊:錯誤:無法解析'/ Users / Stan / Sites / google /中的'child_process' dallas / node_modules / google-auth-library / build / src / auth中的錯誤。/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js找不到模塊:錯誤:可以'在'/ Users / Stan / Sites / google / dallas / node_modules / google-gax / node_modules / google-auth-library / build / src / auth'中解析'child_process'

當我不在上述要求行中輸入時,唯一的問題是未定義“管理員”。

我認為我錯過了一些小的設置問題,但是在此之后,我將不勝感激。

admin SDK僅適用於nodejs。 因此,您不能在前端使用它。

您可以為此創建一個Firebase雲功能。 並將其部署在您的項目中。 然后,您可以在角度應用程序中調用該函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM