Fut*_*cky 6 ember.js firebase emberfire
我目前正在使用电子邮件和密码登录。但我希望能够为每个用户分配一个角色:管理员或用户。我已经读到这是通过使用自定义身份验证方法完成的,但我发现文档不清楚无法使用电子邮件/密码身份验证来实现。
我将如何去设置它?
我目前正在为 ember 使用 firebase emberfire
更新:
文档参考:https : //www.firebase.com/docs/web/guide/login/custom.html
Firebase 刚刚通过 ID 令牌上的自定义用户声明启动了对任何用户基于角色的访问的支持:https : //firebase.google.com/docs/auth/admin/custom-claims
您将定义管理员访问规则:
{
"rules": {
"adminContent": {
".read": "auth.token.admin === true",
".write": "auth.token.admin === true",
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用 Admin SDK 设置用户角色:
// Set admin privilege on the user corresponding to uid.
admin.auth().setCustomUserClaims(uid, {admin: true}).then(() => {
// The new custom claims will propagate to the user's ID token the
// next time a new one is issued.
});
Run Code Online (Sandbox Code Playgroud)
这将传播到相应用户的 ID 令牌声明。
要从客户端上的令牌解析它,请检查:https : //firebase.google.com/docs/auth/admin/custom-claims#access_custom_claims_on_the_client
| 归档时间: |
|
| 查看次数: |
10034 次 |
| 最近记录: |