-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 【北大开源实践】增加数据导出功能 (#294) * feat:添加了一个文件数据导出的功能和相应前端页面 * fix lint * fix conflict --------- Co-authored-by: dayou <[email protected]> * fix: components.d.ts文件ignore * feat: Update README_EN.md * feat: Update README.md * feat:新增预览功能 (#257) * feat:问卷预览功能 * feat:修复样式问题 * fix: 优化预览展示 * refactor: 重构vue3组合式API写法 (#265) * feat: 抽离题型枚举 (#272) * feat: 抽离题型枚举 * fix: 投放的链接加时间戳去掉ifream缓存 * feat: serve端的node engines * feat: 权限接口请求优化以及修复其他问题 (#290) * feat: c端路由改造 (#296) * 【北大开源实践】增加数据导出功能 (#294) * feat:添加了一个文件数据导出的功能和相应前端页面 * fix lint * fix conflict --------- Co-authored-by: dayou <[email protected]> * fix: 删除components.d.ts文件 * 【北大开源实践】- 问卷断点续答 - 前端 (#282) * feat:增加断点续答功能 * feat:增加断点续答功能 * fix: 同步代码并且解决冲突 --------- Co-authored-by: dayou <[email protected]> * fix: 删除components.d.ts文件最终 * 【北大开源实践】-选项限制 (#284) * format: 代码格式化 (#160) * feat: 选项限制 * fix: 同步代码并解决冲突 * fix conflict * fix conflict * fix lint * fix server lint --------- Co-authored-by: dayou <[email protected]> Co-authored-by: XiaoYuan <[email protected]> * feat: 登录失效检测 & 协作冲突检测 (#287) Co-authored-by: Liuxinyi <[email protected]> Co-authored-by: dayou <[email protected]> * fix: peking分支同步develop并解决冲突 * fix: 修正颜色不统一 (#338) * fix: 修正颜色不统一 * fix: 删除server下的lock文件 * 编辑冲突检测 (#351) * perl: 选项配额优化 * fix: pinia改写 * feat: 完善北大课程相关的内容 * fix: 修复断点续答以及样式问题 (#420) * feat: 修改readme * [Feature]: 密码复杂度检测 (#407) * feat: 密码复杂度检测 * chore: 改为服务端校验 * feat: 优化展示 * fix:修复编辑页在不同element版本下表现不一致问题 (#406) * fix: 通过声明element最低版本来确定tab样式表现 * fix lint * feat(选项设置扩展):选择类题型增加选项排列配置 (#403) * build: add optimizeDeps packages * feat(选项设置扩展):选择类题型增加选项排列配置 * feat(选项设置扩展): 验收问题修复 --------- Co-authored-by: jiangchunfu <[email protected]> * fix: 删除多余内容 * feat: 优化登录窗口 * fix: 修复断点续答以及样式问题 fix: 修复选项引用验收bug fix: 修复断点续答问题 fix: 修复断点续答 fix: ignore fix: 修复投票题默认值 fix: 优化断点续答逻辑 fix: 选中图标适应高度 fix: 回退最大最小选择 fix: 修复断点续答 fix: 修复elswitch不更新问题 fix: 修复访问密码更新不生效问题 fix: 修复样式 fix: 修复多选题最大最小限制 fix: 优化断点续答问题 修复多选题命中最多选择后无法取消问题 fix: 修复服务端的富文本解析 fix: lint fix: min error fix: 修复最少最多选择 fix: 修复投票问卷的最少最多选择 fix: 兼容断点续答情况下选项配额为0的情况 fix: 兼容断点续答情况下选项配额为0的情况 fix: 兼容单选题的断点续答下的选项配额 fix: 修复添加选项问题 fix: 前端提示服务的配额已满 fix: 更新填写的过程中配额减少情况 --------- Co-authored-by: sudoooooo <[email protected]> Co-authored-by: Stahsf <[email protected]> Co-authored-by: Jiangchunfu <[email protected]> Co-authored-by: jiangchunfu <[email protected]> * feat: 修改验收问题 (#421) * fix lint --------- Co-authored-by: Oseast <[email protected]> Co-authored-by: sudoooooo <[email protected]> Co-authored-by: chaorenluo <[email protected]> Co-authored-by: Realabiha <[email protected]> Co-authored-by: shiyiting763 <[email protected]> Co-authored-by: yiyeah <[email protected]> Co-authored-by: XiaoYuan <[email protected]> Co-authored-by: Xinyi Liu <[email protected]> Co-authored-by: Liuxinyi <[email protected]> Co-authored-by: nil <[email protected]> Co-authored-by: 王晓聪 <[email protected]> Co-authored-by: taoshuang <[email protected]> Co-authored-by: luch1994 <[email protected]> Co-authored-by: Stahsf <[email protected]> Co-authored-by: Jiangchunfu <[email protected]> Co-authored-by: jiangchunfu <[email protected]> Co-authored-by: luch <[email protected]>
- Loading branch information
1 parent
43001a1
commit b749cfa
Showing
99 changed files
with
2,924 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const mongo = { | ||
url: process.env.XIAOJU_SURVEY_MONGO_URL || 'mongodb://localhost:27017', | ||
dbName: process.env.XIAOJU_SURVER_MONGO_DBNAME || 'xiaojuSurvey', | ||
}; | ||
|
||
const session = { | ||
expireTime: | ||
parseInt(process.env.XIAOJU_SURVEY_JWT_EXPIRES_IN) || 8 * 3600 * 1000, | ||
}; | ||
|
||
const encrypt = { | ||
type: process.env.XIAOJU_SURVEY_ENCRYPT_TYPE || 'aes', | ||
aesCodelength: parseInt(process.env.XIAOJU_SURVEY_ENCRYPT_TYPE_LEN) || 10, //aes密钥长度 | ||
}; | ||
|
||
const jwt = { | ||
secret: process.env.XIAOJU_SURVEY_JWT_SECRET || 'xiaojuSurveyJwtSecret', | ||
expiresIn: process.env.XIAOJU_SURVEY_JWT_EXPIRES_IN || '8h', | ||
}; | ||
|
||
export { mongo, session, encrypt, jwt }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common'; | ||
import { Reflector } from '@nestjs/core'; | ||
import { get } from 'lodash'; | ||
import { NoPermissionException } from 'src/exceptions/noPermissionException'; | ||
import { SurveyNotFoundException } from 'src/exceptions/surveyNotFoundException'; | ||
import { SessionService } from 'src/modules/survey/services/session.service'; | ||
import { SurveyMetaService } from 'src/modules/survey/services/surveyMeta.service'; | ||
import { WorkspaceMemberService } from 'src/modules/workspace/services/workspaceMember.service'; | ||
import { CollaboratorService } from 'src/modules/survey/services/collaborator.service'; | ||
|
||
@Injectable() | ||
export class SessionGuard implements CanActivate { | ||
constructor( | ||
private reflector: Reflector, | ||
private readonly sessionService: SessionService, | ||
private readonly surveyMetaService: SurveyMetaService, | ||
private readonly workspaceMemberService: WorkspaceMemberService, | ||
private readonly collaboratorService: CollaboratorService, | ||
) {} | ||
|
||
async canActivate(context: ExecutionContext): Promise<boolean> { | ||
const request = context.switchToHttp().getRequest(); | ||
const user = request.user; | ||
const sessionIdKey = this.reflector.get<string>( | ||
'sessionId', | ||
context.getHandler(), | ||
); | ||
|
||
const sessionId = get(request, sessionIdKey); | ||
|
||
if (!sessionId) { | ||
throw new NoPermissionException('没有权限'); | ||
} | ||
|
||
const saveSession = await this.sessionService.findOne(sessionId); | ||
|
||
request.saveSession = saveSession; | ||
|
||
const surveyId = saveSession.surveyId; | ||
|
||
const surveyMeta = await this.surveyMetaService.getSurveyById({ surveyId }); | ||
|
||
if (!surveyMeta) { | ||
throw new SurveyNotFoundException('问卷不存在'); | ||
} | ||
|
||
request.surveyMeta = surveyMeta; | ||
|
||
// 兼容老的问卷没有ownerId | ||
if ( | ||
surveyMeta.ownerId === user._id.toString() || | ||
surveyMeta.owner === user.username | ||
) { | ||
// 问卷的owner,可以访问和操作问卷 | ||
return true; | ||
} | ||
|
||
if (surveyMeta.workspaceId) { | ||
const memberInfo = await this.workspaceMemberService.findOne({ | ||
workspaceId: surveyMeta.workspaceId, | ||
userId: user._id.toString(), | ||
}); | ||
if (!memberInfo) { | ||
throw new NoPermissionException('没有权限'); | ||
} | ||
return true; | ||
} | ||
|
||
const permissions = this.reflector.get<string[]>( | ||
'surveyPermission', | ||
context.getHandler(), | ||
); | ||
|
||
if (!Array.isArray(permissions) || permissions.length === 0) { | ||
throw new NoPermissionException('没有权限'); | ||
} | ||
|
||
const info = await this.collaboratorService.getCollaborator({ | ||
surveyId, | ||
userId: user._id.toString(), | ||
}); | ||
|
||
if (!info) { | ||
throw new NoPermissionException('没有权限'); | ||
} | ||
request.collaborator = info; | ||
if ( | ||
permissions.some((permission) => info.permissions.includes(permission)) | ||
) { | ||
return true; | ||
} | ||
throw new NoPermissionException('没有权限'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { Provider } from '@nestjs/common'; | ||
|
||
import { Logger } from './index'; | ||
import { XiaojuSurveyLogger } from './index'; | ||
|
||
export const LoggerProvider: Provider = { | ||
provide: Logger, | ||
useClass: Logger, | ||
provide: XiaojuSurveyLogger, | ||
useClass: XiaojuSurveyLogger, | ||
}; |
Oops, something went wrong.