mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 01:38:19 +08:00
core: 修复domain_create不能正确重定向的问题
This commit is contained in:
1 parent
84c1e9e0e4
commit
89857de04f
4 files changed
+8
-4
No files matched your search
@@ -322,7 +322,7 @@ Hidden: 隐藏
|
||||
Hide all tags: 隐藏所有标签
|
||||
Hide categorical tags: 隐藏分类标签
|
||||
Highlight discussions: 高亮讨论
|
||||
Highlight: 高亮讨论
|
||||
Highlight: 高亮
|
||||
Hint: 提示
|
||||
home_account: 账户设置
|
||||
home_domain_account: 当前域的设置
|
||||
|
||||
@@ -202,7 +202,7 @@ Hidden: 隱藏
|
||||
Hide all tags: 隱藏所有標籤
|
||||
Hide categorical tags: 隱藏分類標籤
|
||||
Highlight discussions: 高亮討論
|
||||
Highlight: 高亮討論
|
||||
Highlight: 高亮
|
||||
home_account: 賬戶設定
|
||||
home_domain_account: 當前域的設定
|
||||
home_domain_create: 創建域
|
||||
|
||||
@@ -85,6 +85,7 @@ export const HomeworkNotLiveError = Err('HomeworkNotLiveError', ForbiddenError,
|
||||
export const HomeworkNotAttendedError = Err('HomeworkNotAttendedError', ForbiddenError, "You haven't claimed this homework yet.");
|
||||
export const RoleAlreadyExistError = Err('RoleAlreadyExistError', ForbiddenError, 'This role already exists.');
|
||||
export const CsrfTokenError = Err('CsrfTokenError', ForbiddenError, 'CsrfTokenError');
|
||||
export const DomainAlreadyExistsError = Err('DomainAlreadyExistsError', ForbiddenError, 'The domain {0} already exists.');
|
||||
export const DomainJoinForbiddenError = Err('DomainJoinForbiddenError', ForbiddenError, 'You are not allowed to join the domain. The link is either invalid or expired.');
|
||||
export const DomainJoinAlreadyMemberError = Err('DomainJoinAlreadyMemberError', ForbiddenError, 'Failed to join the domain. You are already a member.');
|
||||
export const InvalidJoinInvitationCodeError = Err('InvalidJoinInvitationCodeError', ForbiddenError, 'The invitation code you provided is invalid.');
|
||||
@@ -136,6 +137,7 @@ global.Hydro.error = {
|
||||
ContestNotLiveError,
|
||||
ContestScoreboardHiddenError,
|
||||
ContestAlreadyAttendedError,
|
||||
DomainAlreadyExistsError,
|
||||
DomainJoinAlreadyMemberError,
|
||||
DomainJoinForbiddenError,
|
||||
InvalidJoinInvitationCodeError,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import {
|
||||
VerifyPasswordError, UserAlreadyExistError, InvalidTokenError,
|
||||
NotFoundError, UserNotFoundError, PermissionError,
|
||||
NotFoundError, UserNotFoundError, PermissionError, DomainAlreadyExistsError,
|
||||
} from '../error';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
@@ -292,10 +292,12 @@ class HomeDomainCreateHandler extends Handler {
|
||||
@param('bulletin', Types.String, isContent)
|
||||
@param('gravatar', Types.String, true, isEmail)
|
||||
async post(_: string, id: string, name: string, bulletin: string, gravatar: string) {
|
||||
const doc = await domain.get(id);
|
||||
if (doc) throw new DomainAlreadyExistsError(id);
|
||||
gravatar = gravatar || this.user.gravatar || this.user.mail || 'guest@hydro.local';
|
||||
const domainId = await domain.add(id, this.user._id, name, bulletin);
|
||||
await domain.edit(domainId, { gravatar });
|
||||
this.response.redirect = this.url('domain_manage', { domainId });
|
||||
this.response.redirect = this.url('domain_dashboard', { domainId });
|
||||
this.response.body = { domainId };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user