2018-06-04 00:06:17 +08:00
|
|
|
(function (global, document) {
|
2018-06-24 10:01:21 +08:00
|
|
|
"use strict";
|
2018-06-04 00:06:17 +08:00
|
|
|
|
|
|
|
// Get self details.
|
|
|
|
global.selfGet = function(callback) {
|
|
|
|
var json = {
|
2018-06-20 11:36:49 +08:00
|
|
|
"ownerToken": global.cookieGet("commentoOwnerToken"),
|
2018-06-04 00:06:17 +08:00
|
|
|
};
|
|
|
|
|
2018-08-08 14:00:59 +08:00
|
|
|
if (json.ownerToken === undefined) {
|
2018-12-20 13:48:43 +08:00
|
|
|
document.location = global.origin + "/login";
|
2018-08-08 14:00:59 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-20 13:48:43 +08:00
|
|
|
global.post(global.origin + "/api/owner/self", json, function(resp) {
|
2018-06-04 00:06:17 +08:00
|
|
|
if (!resp.success || !resp.loggedIn) {
|
2018-08-08 14:00:59 +08:00
|
|
|
global.cookieDelete("commentoOwnerToken");
|
2018-12-20 13:48:43 +08:00
|
|
|
document.location = global.origin + "/login";
|
2018-06-04 00:06:17 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
global.owner = resp.owner;
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-12-20 13:48:43 +08:00
|
|
|
}(window.commento, document));
|