commento/frontend/js/self.js

28 lines
655 B
JavaScript
Raw Normal View History

2018-06-04 00:06:17 +08:00
(function (global, document) {
"use strict";
2018-06-04 00:06:17 +08:00
// Get self details.
global.selfGet = function(callback) {
var json = {
"ownerToken": global.cookieGet("commentoOwnerToken"),
2018-06-04 00:06:17 +08:00
};
if (json.ownerToken === undefined) {
document.location = global.origin + "/login";
return;
}
global.post(global.origin + "/api/owner/self", json, function(resp) {
2018-06-04 00:06:17 +08:00
if (!resp.success || !resp.loggedIn) {
global.cookieDelete("commentoOwnerToken");
document.location = global.origin + "/login";
2018-06-04 00:06:17 +08:00
return;
}
global.owner = resp.owner;
callback();
});
};
}(window.commento, document));