2013-02-18 48 views
0

后,我设计用火力地堡一道数学题的网站,我想,当有人在日志中显示的问题。显示文本登录

我想在伪代码是什么,

if user logged in 
document.write([problem]) 
else 
document.write(Please login to see the problem) 

任何想法?

回答

1

当使用火力地堡简单登录,于FirebaseAuthClient您的实例将定义被调用的任何时间的用户更改登录状态的回调函数。

https://www.firebase.com/docs/security/simple-login-overview.html

var chatRef = new Firebase('https://SampleChat.firebaseIO-demo.com'); 
var authClient = new FirebaseAuthClient(chatRef, function(error, user) { 
    if (user) { 
    // user authenticated with Firebase 
    } else if (error) { 
    // an error occurred authenticating the user 
    } else { 
    // user is logged out 
    } 
}); 

对于你的情况,如果你有一个用户对象,你可以隐藏任何登录相关的用户界面,并显示问题,否则,隐藏的问题,并显示任何登录相关的UI 。

然后,登录用户,选择火力地堡简单登录认证供应商的一个或多个,配置在锻造(通过https://<your-firebase>.firebaseio.com访问)该提供商,并尝试通过对用户进行认证:

authClient.login(<provider>, <options>); 

希望这有帮助!

+0

所以我应该写的,'VAR chatRef =新的火力地堡( 'https://开头 .firebaseIO-demo.com'); var authClient = new FirebaseAuthClient(chatRef,function(error,user){if(user){ } document.write(“Factor x^2 + 2x + 1”) } else if(error){ document.write (“登录后再次尝试。”) } else { document.write(“请登录查看问题”) } });'是吗? – mathguy56 2013-02-19 15:48:57

+0

@ShenalSanthush与火力地堡URL(somename.firebaseio.com),看起来不错监测用户认证状态更换' .firebaseIO-demo.com'后。然后,一旦用户点击应用程序中的登录按钮,就调用'authClient.login(...)'。 – 2013-02-19 18:03:28

+0

@ShenalSanthush要使用火力地堡简单登录看到电子邮件/密码验证的完整的示例,请参见[https://groups.google.com/forum/?hl=en_US&fromgroups=#!topic/firebase-talk/POcs7m5gihg](https: //groups.google.com/forum/?hl=en_US&fromgroups=#!topic/firebase-talk/POcs7m5gihg)。 – 2013-02-19 18:53:30