mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add server-loader (#816)
This commit is contained in:
1 parent
3302480348
commit
97720efb65
57 files changed
+1328
-1131
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { escapeRegExp, pick, uniq } from 'lodash';
|
||||
import { LRUCache } from 'lru-cache';
|
||||
import { Collection, Filter, ObjectId } from 'mongodb';
|
||||
import { serializer } from '@hydrooj/framework';
|
||||
import { LoginError, UserAlreadyExistError, UserNotFoundError } from '../error';
|
||||
import {
|
||||
Authenticator, BaseUserDict, FileInfo, GDoc,
|
||||
@@ -8,7 +9,6 @@ import {
|
||||
} from '../interface';
|
||||
import avatar from '../lib/avatar';
|
||||
import pwhash from '../lib/hash.hydro';
|
||||
import serializer from '../lib/serializer';
|
||||
import * as bus from '../service/bus';
|
||||
import db from '../service/db';
|
||||
import { Value } from '../typeutils';
|
||||
@@ -165,16 +165,20 @@ export class User {
|
||||
return user;
|
||||
}
|
||||
|
||||
serialize(options) {
|
||||
serialize(_, h) {
|
||||
if (!this._isPrivate) {
|
||||
const fields = ['_id', 'uname', 'mail', 'perm', 'role', 'priv', 'regat', 'loginat', 'tfa', 'authn'];
|
||||
if (options.showDisplayName) fields.push('displayName');
|
||||
if (h?.user?.hasPerm(PERM.PERM_VIEW_DISPLAYNAME)) fields.push('displayName');
|
||||
return pick(this, fields);
|
||||
}
|
||||
return JSON.stringify(this, serializer({ showDisplayName: options.showDisplayName }, true));
|
||||
return JSON.stringify(this, serializer(true, h));
|
||||
}
|
||||
}
|
||||
|
||||
declare module '@hydrooj/framework' {
|
||||
interface UserModel extends User { }
|
||||
}
|
||||
|
||||
function handleMailLower(mail: string) {
|
||||
const [n, d] = mail.trim().toLowerCase().split('@');
|
||||
const [name] = n.split('+');
|
||||
|
||||
Reference in new issue
Block a user