3

我已经设置了everyauth,看起来很不错。

现在,正如这个NodeTuts 插曲所示,必须去http://www.example.com/auth/facebookorhttp://www.example.com/auth/twitter才能进行身份验证。

如何配置everyauth允许我将 JavaScript 事件附加到按钮以触发身份验证?

例如,在下面的代码中,点击底部的按钮应该会弹出一个 Facebook 身份验证窗口。我该如何使用everyauth?

<html>
    <head>
      <title>My Facebook Login Page</title>
    </head>
    <body>
      <div id="fb-root"></div>
      <script>
        window.fbAsyncInit = function() {
          FB.init({
            appId      : 'YOUR_APP_ID',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
          });
        };
        (function(d){
           var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
           js = d.createElement('script'); js.id = id; js.async = true;
           js.src = "//connect.facebook.net/en_US/all.js";
           d.getElementsByTagName('head')[0].appendChild(js);
         }(document));
      </script>
      <div class="fb-login-button">Login with Facebook</div>
    </body>
</html>
4

1 回答 1

1

查看 Rob righter 的 easy-oauth 库:https ://github.com/robrighter/easy-oauth/blob/master/lib/easy-oauth.js

他注入客户端js,然后绕过路由。

于 2012-03-06T20:41:26.670 回答