我自己的用户数据库的Disqus

时间:2014-09-03 12:55:57

标签: javascript symfony disqus

首先,我想询问我是否可以使用自己的用户数据库登录disqus?我想我们能做到吗?

我不知道我还能做什么。我现在完全被困住了。

我知道我必须使用SSO(https://help.disqus.com/customer/portal/articles/236206-single-sign-on#configure-domain)。我做了所有设置,但我必须错过一些东西......

My Complete Disqus配置:

据我所知,用户信息是我自己的用户数据,已经登录到我们的网站。

var DISQUS_SECRET = "SECRET_HERE";
var DISQUS_PUBLIC = "PUBLIC_HERE";

function disqusSignon(user) {
    var disqusData = {
        id: user.id,
        username: user.username,
        email: user.email
    };

    var disqusStr = JSON.stringify(disqusData);
    var timestamp = Math.round(+new Date() / 1000);

    // This line is important! In official example, they were using NodeJS Buffer class. As they told in example, i have encrypted with window.btoa insted of NodeJS Buffer.
    var message = window.btoa(disqusStr).toString('base64');
    var result = CryptoJS.HmacSHA1(message + " " + timestamp, DISQUS_SECRET);
    var hexsig = CryptoJS.enc.Hex.stringify(result);
        return message + " " + hexsig + " " + timestamp;
    }

    // getting the user data from twig
    var user = {
        id: {{ app.user.id }},
        username: "{{ app.user.username }}",
        email: "{{ app.user.email }}"
    };

    //generating auth_s3 key
    var auth_key = disqusSignon(user);

    var disqus_config = function () {
        this.page.remote_auth_s3 = auth_key;
        this.page.api_key = DISQUS_PUBLIC;

        this.sso = {
            name:    "Oyun Maceraları",
            icon:    "http://www.oyunmaceralari.com/favicon.png",
            url:     "http://oyunmaceralari.com/login-popup",
            logout:  "http://oyunmaceralari.com/logout"
        };
    };

    var disqus_shortname = 'xxxxxx';

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();

0 个答案:

没有答案