mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: domain_del
This commit is contained in:
1 parent
60f8d4ce49
commit
06faa233f8
5 files changed
+33
-4
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.2.39",
|
||||
"version": "3.2.40",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -41,6 +41,7 @@ export function registerResolver(
|
||||
const res = await func(arg, ctx, info);
|
||||
if (typeof res !== 'object') return res;
|
||||
if (handlers[value]) Object.assign(res, handlers[value]);
|
||||
ctx.parent = res;
|
||||
return res;
|
||||
};
|
||||
if (handlers[typeName]) handlers[typeName][key.split('(')[0].trim()] = wrappedFunc;
|
||||
|
||||
@@ -2,8 +2,8 @@ import { load } from 'js-yaml';
|
||||
import { Dictionary } from 'lodash';
|
||||
import moment from 'moment-timezone';
|
||||
import {
|
||||
DomainJoinAlreadyMemberError, DomainJoinForbiddenError, InvalidJoinInvitationCodeError,
|
||||
RoleAlreadyExistError, ValidationError,
|
||||
DomainJoinAlreadyMemberError, DomainJoinForbiddenError, ForbiddenError,
|
||||
InvalidJoinInvitationCodeError, RoleAlreadyExistError, ValidationError,
|
||||
} from '../error';
|
||||
import type { DomainDoc } from '../interface';
|
||||
import avatar from '../lib/avatar';
|
||||
@@ -56,6 +56,7 @@ class DomainEditHandler extends ManageHandler {
|
||||
}
|
||||
|
||||
async post(args) {
|
||||
if (args.operation) return;
|
||||
const $set = {};
|
||||
for (const key in args) {
|
||||
if (DOMAIN_SETTINGS_BY_KEY[key]) $set[key] = args[key];
|
||||
@@ -63,6 +64,13 @@ class DomainEditHandler extends ManageHandler {
|
||||
await domain.edit(args.domainId, $set);
|
||||
this.response.redirect = this.url('domain_dashboard');
|
||||
}
|
||||
|
||||
async postDelete({ password }) {
|
||||
this.user.checkPassword(password);
|
||||
if (this.domain.owner === this.user._id) throw new ForbiddenError('You are not the owner of this domain.');
|
||||
await domain.del(this.domainId);
|
||||
this.response.redirect = this.url('home_domain', { domainId: 'system' });
|
||||
}
|
||||
}
|
||||
|
||||
class DomainDashboardHandler extends ManageHandler {
|
||||
|
||||
Reference in new issue
Block a user