【发布时间】:2019-01-03 10:46:20
【问题描述】:
我正在尝试使用 Firebase 为我的网络应用创建登录界面。我想使用 Firebase 自己的身份验证系统将 user role 添加到我的帐户中。 (电子邮件)。但它不支持添加user role 的任何选项。例如“管理员”和“用户”。
这适用于 Firebase(当前为 5.7.2)和 HTML5。
login.js(当前登录验证)
(function(){
var ui = new firebaseui.auth.AuthUI(firebase.auth());
var uiConfig = {
callbacks: {
signInSuccessWithAuthResult: function(authResult, redirectUrl) {
// User successfully signed in.
// Return type determines whether we continue the redirect automatically
// or whether we leave that to developer to handle.
return true;
},
uiShown: function() {
// The widget is rendered.
// Hide the loader.
document.getElementById('loader').style.display = 'none';
}
},
// Will use popup for IDP Providers sign-in flow instead of the default, redirect.
signInFlow: 'popup',
signInSuccessUrl: 'index.html',
signInOptions: [
// Leave the lines as is for the providers you want to offer your users.
firebase.auth.EmailAuthProvider.PROVIDER_ID,
],
};
ui.start('#firebaseui-auth-container', uiConfig);
})()
我希望在 js 中的某处添加一个选项或用户角色字段作为电子邮件的唯一标识符? (adminabc@xx.com = admin, userabc@xx.com = user) 或 firebase 的附加字段。 (在数据库中添加一个专用表,而不是使用实现的用户身份验证。)
【问题讨论】:
标签: html firebase firebase-authentication