mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
兼容IE
This commit is contained in:
1 parent
627e64a901
commit
1df19a7aa9
17 files changed
+62
-105
No files matched your search
@@ -80,11 +80,12 @@ class HomeSecurityHandler extends Handler {
|
||||
|
||||
async get() {
|
||||
// TODO(iceboy): pagination? or limit session count for uid?
|
||||
// TODO(masnn): UA & IP
|
||||
const sessions = await token.getSessionListByUid(this.user._id);
|
||||
const parsed = sessions.map((session) => ({
|
||||
...session,
|
||||
updateUa: useragent.parse(session.updateUa || session.createUa || ''),
|
||||
updateGeoip: geoip.ip2geo(session.updateIp || session.createIp, this.user.viewLang),
|
||||
// updateUa: useragent.parse(session.updateUa || session.createUa || ''),
|
||||
// updateGeoip: geoip.ip2geo(session.updateIp || session.createIp, this.user.viewLang),
|
||||
_id: md5(session._id),
|
||||
isCurrent: session._id === this.session._id,
|
||||
}));
|
||||
@@ -116,7 +117,7 @@ class HomeSecurityHandler extends Handler {
|
||||
|
||||
async postDeleteToken({ tokenDigest }) {
|
||||
const sessions = await token.getSessionListByUid(this.user._id);
|
||||
for (const session in sessions) {
|
||||
for (const session of sessions) {
|
||||
if (tokenDigest === md5(session._id)) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await token.delete(session._id, token.TYPE_SESSION);
|
||||
@@ -128,7 +129,7 @@ class HomeSecurityHandler extends Handler {
|
||||
|
||||
async postDeleteAllTokens() {
|
||||
await token.deleteByUid(this.user._id);
|
||||
this.back();
|
||||
this.response.redirect = '/login';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ class ProblemImportHandler extends Handler {
|
||||
if (pid) pdoc.pid = pid;
|
||||
if (hidden) pdoc.hidden = true;
|
||||
const _id = await problem.add(pdoc);
|
||||
console.log(_id);
|
||||
await problem.setTestdata(_id, testdata);
|
||||
this.response.body = { pid: pid || _id };
|
||||
this.response.redirect = `/p/${pid || _id}/settings`;
|
||||
|
||||
+11
-10
@@ -32,25 +32,26 @@ class ProblemHandler extends Handler {
|
||||
this.checkPerm(PERM_VIEW_PROBLEM);
|
||||
}
|
||||
|
||||
async get({ page = 1, category = null }) {
|
||||
async get({ page = 1, category = '' }) {
|
||||
this.response.template = 'problem_main.html';
|
||||
const q = {};
|
||||
let psdict = {};
|
||||
if (category) q.category = category;
|
||||
if (!this.user.hasPerm(PERM_VIEW_PROBLEM_HIDDEN)) q.hidden = false;
|
||||
const pdocs = await problem.getMany(q, { pid: 1 }, page, constants.PROBLEM_PER_PAGE);
|
||||
const [pdocs, pcount] = await paginate(
|
||||
problem.getMulti(q).sort({ pid: 1 }),
|
||||
page,
|
||||
constants.PROBLEM_PER_PAGE,
|
||||
);
|
||||
if (this.user.hasPerm(PERM_LOGGEDIN)) {
|
||||
psdict = await problem.getListStatus(this.user._id, pdocs.map((pdoc) => pdoc._id));
|
||||
}
|
||||
const path = [
|
||||
['Hydro', '/'],
|
||||
['problem_main', null],
|
||||
];
|
||||
this.response.body = {
|
||||
path: [
|
||||
['Hydro', '/'],
|
||||
['problem_main', null],
|
||||
],
|
||||
page,
|
||||
pdocs,
|
||||
psdict,
|
||||
category: '',
|
||||
path, page, pcount, pdocs, psdict, category,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user