mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: allow banReason option
This commit is contained in:
1 parent
5c3e2d8571
commit
be0423fe93
4 files changed
+5
-5
No files matched your search
@@ -129,7 +129,7 @@ class UserLoginHandler extends Handler {
|
|||||||
if (udoc._tfa && !verifyToken(udoc._tfa, tfa)) throw new InvalidTokenError('2FA');
|
if (udoc._tfa && !verifyToken(udoc._tfa, tfa)) throw new InvalidTokenError('2FA');
|
||||||
udoc.checkPassword(password);
|
udoc.checkPassword(password);
|
||||||
await user.setById(udoc._id, { loginat: new Date(), loginip: this.request.ip });
|
await user.setById(udoc._id, { loginat: new Date(), loginip: this.request.ip });
|
||||||
if (!udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) throw new BlacklistedError(uname);
|
if (!udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) throw new BlacklistedError(uname, udoc.banReason);
|
||||||
this.session.viewLang = '';
|
this.session.viewLang = '';
|
||||||
this.session.uid = udoc._id;
|
this.session.uid = udoc._id;
|
||||||
this.session.sudo = null;
|
this.session.sudo = null;
|
||||||
@@ -471,5 +471,5 @@ export async function apply(ctx) {
|
|||||||
ctx.Route('user_lostpass', '/lostpass', UserLostPassHandler);
|
ctx.Route('user_lostpass', '/lostpass', UserLostPassHandler);
|
||||||
ctx.Route('user_lostpass_with_code', '/lostpass/:code', UserLostPassWithCodeHandler);
|
ctx.Route('user_lostpass_with_code', '/lostpass/:code', UserLostPassWithCodeHandler);
|
||||||
ctx.Route('user_delete', '/user/delete', UserDeleteHandler, PRIV.PRIV_USER_PROFILE);
|
ctx.Route('user_delete', '/user/delete', UserDeleteHandler, PRIV.PRIV_USER_PROFILE);
|
||||||
ctx.Route('user_detail', '/user/:uid', UserDetailHandler);
|
ctx.Route('user_detail', '/user/:uid(-?\\d+)', UserDetailHandler);
|
||||||
}
|
}
|
||||||
@@ -152,6 +152,7 @@ AccountSetting(
|
|||||||
'Choose the background image in your profile page.'),
|
'Choose the background image in your profile page.'),
|
||||||
Setting('setting_storage', 'unreadMsg', 0, 'number', 'Unread Message Count', null, FLAG_DISABLED | FLAG_HIDDEN),
|
Setting('setting_storage', 'unreadMsg', 0, 'number', 'Unread Message Count', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||||
Setting('setting_storage', 'badge', '', 'text', 'badge info', null, FLAG_DISABLED | FLAG_HIDDEN),
|
Setting('setting_storage', 'badge', '', 'text', 'badge info', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||||
|
Setting('setting_storage', 'banReason', '', 'text', 'ban reason', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||||
);
|
);
|
||||||
|
|
||||||
DomainSetting(
|
DomainSetting(
|
||||||
|
|||||||
@@ -400,9 +400,9 @@ class UserModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ArgMethod
|
@ArgMethod
|
||||||
static ban(uid: number) {
|
static ban(uid: number, reason = '') {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
UserModel.setPriv(uid, PRIV.PRIV_NONE),
|
UserModel.setById(uid, { priv: PRIV.PRIV_NONE, banReason: reason }),
|
||||||
token.delByUid(uid),
|
token.delByUid(uid),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import UserSelectAutoComplete from './components/autocomplete/UserSelectAutoComp
|
|||||||
export {
|
export {
|
||||||
load, AutoComplete, UserSelectAutoComplete, ProblemSelectAutoComplete, DomainSelectAutoComplete, CustomSelectAutoComplete,
|
load, AutoComplete, UserSelectAutoComplete, ProblemSelectAutoComplete, DomainSelectAutoComplete, CustomSelectAutoComplete,
|
||||||
};
|
};
|
||||||
export const { UserContext, UiContext } = window;
|
|
||||||
export function addPage(page: import('./misc/Page').Page | (() => Promise<void> | void)) {
|
export function addPage(page: import('./misc/Page').Page | (() => Promise<void> | void)) {
|
||||||
window.Hydro.extraPages.push(page);
|
window.Hydro.extraPages.push(page);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user