[英]How to get the user's details after logging in with social media?
I am using firebase for authentication and using plain javascript (not AngularJS or any other framework such as Angular2 or ionic). 我正在使用Firebase进行身份验证并使用普通的javascript(不是AngularJS或任何其他框架,例如Angular2或ionic)。 After successful signing up with google or Facebook, I want to display the user name, use email and user image. 在通过google或Facebook成功注册后,我想显示用户名,使用电子邮件和用户图像。
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
var displayName = user.displayName;
var email = user.email;
var photoURL = user.photoURL;
} else {
// User is not logged in, redirect to where you need to.
console.log("Logged out");
}
The above is the snippet on the page which should show up after successful sign up. 上面是页面上的代码段,成功注册后应该会显示出来。
And I used the following to display the details, but the page showed up just what is written within the tags. 我使用以下内容来显示详细信息,但是页面仅显示了标记中编写的内容。
<p class="isLoggedIn">Logged In: {{user_displayName}} ({{user_email}})<p>
Where am I going wrong? 我要去哪里错了?
Any kind of help would be greatly appreciated. 任何形式的帮助将不胜感激。 Thanks. 谢谢。
your variables are only available inside the method you will not get them outside the function. 您的变量仅在方法内部可用,而不会在函数外部获取。 Also if you are not using the AngularJS then you are doing it wrong to put values in html like this, its angular way to bind data to view. 另外,如果您不使用AngularJS,则将这样的值放入html(将数据绑定到视图的角度方法)的做法是错误的。
See this on how to write data using plain javascript: https://stackoverflow.com/a/10507608/4428159 参见此内容,了解如何使用普通的javascript编写数据: https : //stackoverflow.com/a/10507608/4428159
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.