我是网站创建的新手,我正在使用登录/会员功能。如果会员注册,我将如何动态创建新的永久性网页(个人资料页面)?
//where I would use the code
//Javascript
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
//Navigate to the User's page, which does not yet exist
var url = "http://example.com/" + user.uid;
window.location = url;
} else {
// No user is signed in.
}
});
答案 0 :(得分:0)
答案在文档中。 https://firebase.google.com/docs/auth/web/manage-users#get_a_users_profile
我建议您阅读一些FireBase文档,您可能需要了解FireBase路由的工作原理(假设您将其用作服务器)
但是,根据您的要求(即用户个人资料页面),您只需抓取数据并将其显示在常规个人资料网址上。
var user = firebase.auth().currentUser;
var name, email, photoUrl, uid;
if (user != null) {
name = user.displayName;
email = user.email;
photoUrl = user.photoURL;
uid = user.uid; // The user's ID, unique to the Firebase project. Do NOT use
// this value to authenticate with your backend server, if
// you have one. Use User.getToken() instead.
}