Use auth cookie in the client

feature/auth
Nicolas Le Manchet 10 years ago
parent f42e70c768
commit 8550859366

@ -7,6 +7,20 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
var Postbox = function(parent) {
if (config['auth'] === true) {
var authCookie = utils.cookie('auth');
if (! authCookie) {
jade.set("cookie", {'valid': false});
} else {
var authData = lib.itsdangerous(authCookie)
if (! authData) {
jade.set("cookie", {'valid': false});
} else {
jade.set("cookie", {'valid': true, 'data': authData});
}
}
}
var el = $.htmlify(jade.render("postbox"));
// callback on success (e.g. to toggle the reply button)

@ -16,7 +16,7 @@ mixin form(style)
div(class='isso-postbox')
if conf.auth
if cookie.valid
p=i18n('postbox-auth-commenting-as') + ' ' + cookie.username
p=i18n('postbox-auth-commenting-as') + ' ' + cookie.data.username
+form('visibility: hidden;')
else
p=i18n('postbox-auth-required')

@ -11,7 +11,6 @@ require(["app/lib/ready", "app/config", "app/i18n", "app/api", "app/isso", "app/
jade.set("i18n", i18n.translate);
jade.set("pluralize", i18n.pluralize);
jade.set("svg", svg);
jade.set("cookie", {'valid': true, 'username': 'Nicolas'})
domready(function() {

Loading…
Cancel
Save