用户详情页面

This commit is contained in:
masnn committed 2020-04-10 23:17:52 +08:00
1 parent 26c467f60f
commit 0e590ebe0d
4 files changed
+64 -214

No files matched your search

+3 -1
View File
@@ -65,7 +65,9 @@ module.exports = {
let result = await coll.deleteOne({ _id: tokenId, tokenType });
return !!result.deletedCount;
},
async getMostRecentSessionByUid(uid) {
return await coll.findOne({ data: { uid }, token_type: this.TYPE_SESSION }, { sort: { updateAt: -1 } });
},
init: () => Promise.all([
coll.createIndex([{ uid: 1 }, { tokenType: 1 }, { updateAt: -1 }], { sparse: true }),
coll.createIndex('expireAt', { expireAfterSeconds: 0 })
+6 -1
View File
@@ -1,7 +1,7 @@
const
system = require('./system'),
{ UserNotFoundError, UserAlreadyExistError } = require('../error'),
pwhash = require('./lib/pwhash'),
pwhash = require('../lib/pwhash'),
validator = require('../lib/validator'),
db = require('../service/db'),
coll = db.collection('user'),
@@ -18,6 +18,11 @@ class USER {
this.lang = user.language || 'zh_CN';
this.codeLang = user.codeLang || 'c';
this.codeTemplate = user.codeTemplate || '';
this.regat = user.regat;
this.loginat = user.loginat;
this.bio = user.bio || '';
this.nAccept = user.nAccept || 0;
this.nSubmit = user.nSubmit || 0;
}
hasPerm(perm) {
return this.perm == '-' || (this.perm || '').includes(perm);