mirror of
https://github.com/certd/certd.git
synced 2026-04-15 05:00:52 +08:00
fix: 修复偶尔下载证书报未授权的错误
This commit is contained in:
@@ -40,9 +40,7 @@ export class LoginController extends BaseController {
|
||||
}
|
||||
|
||||
private writeTokenCookie(token: { expire: any; token: any }) {
|
||||
this.ctx.cookies.set("certd_token", token.token, {
|
||||
maxAge: 1000 * token.expire
|
||||
});
|
||||
// this.loginService.writeTokenCookie(this.ctx,token);
|
||||
}
|
||||
|
||||
@Post('/loginBySms', { summary: Constants.per.guest })
|
||||
|
||||
@@ -70,6 +70,8 @@ export class ConnectController extends BaseController {
|
||||
})
|
||||
return this.ok({ loginUrl, ticket });
|
||||
}
|
||||
|
||||
|
||||
@Get('/callback/:type', { summary: Constants.per.guest })
|
||||
public async callback(@Param('type') type: string, @Query() query: Record<string, string>) {
|
||||
|
||||
@@ -154,10 +156,15 @@ export class ConnectController extends BaseController {
|
||||
});
|
||||
}
|
||||
|
||||
this.writeTokenCookie(loginRes);
|
||||
//返回登录成功token
|
||||
return this.ok(loginRes);
|
||||
}
|
||||
|
||||
private writeTokenCookie(token: { expire: any; token: any }) {
|
||||
// this.loginService.writeTokenCookie(this.ctx,token);
|
||||
}
|
||||
|
||||
|
||||
@Post('/autoRegister', { summary: Constants.per.guest })
|
||||
public async autoRegister(@Body(ALL) body: { validationCode: string, type: string }) {
|
||||
@@ -183,6 +190,7 @@ export class ConnectController extends BaseController {
|
||||
});
|
||||
|
||||
const loginRes = await this.loginService.generateToken(newUser);
|
||||
this.writeTokenCookie(loginRes);
|
||||
return this.ok(loginRes);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,12 +162,15 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
||||
|
||||
@Get('/download', { summary: Constants.per.authOnly })
|
||||
async download(@Query('id') id: number) {
|
||||
await this.checkOwner(this.getService(),id,"read");
|
||||
const {userId,projectId} =await this.checkOwner(this.getService(),id,"read");
|
||||
const certInfo = await this.getService().info(id)
|
||||
if (certInfo == null) {
|
||||
throw new CommonException('file not found');
|
||||
}
|
||||
if (certInfo.userId !== this.getUserId()) {
|
||||
if (certInfo.userId !== userId) {
|
||||
throw new CommonException('file not found');
|
||||
}
|
||||
if (projectId && certInfo.projectId !== projectId) {
|
||||
throw new CommonException('file not found');
|
||||
}
|
||||
// koa send file
|
||||
|
||||
@@ -241,7 +241,7 @@ export class HistoryController extends CrudController<HistoryService> {
|
||||
history = await this.service.getLastHistory(pipelineId);
|
||||
}
|
||||
if (history == null) {
|
||||
throw new CommonException('historyId is null');
|
||||
throw new CommonException('流水线还未运行过');
|
||||
}
|
||||
const {projectId} = await this.getProjectUserIdRead()
|
||||
if (projectId) {
|
||||
|
||||
@@ -199,6 +199,12 @@ export class LoginService {
|
||||
return this.generateToken(info);
|
||||
}
|
||||
|
||||
writeTokenCookie(ctx:any,token: { expire: any; token: any }) {
|
||||
ctx.cookies.set("certd_token", token.token, {
|
||||
maxAge: 1000 * token.expire
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成token
|
||||
|
||||
@@ -842,7 +842,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
.addSelect("count(1)", "count")
|
||||
.where({
|
||||
userId: param.userId,
|
||||
projectId: param.projectId
|
||||
projectId: param.projectId,
|
||||
isTemplate: false
|
||||
})
|
||||
.groupBy("status")
|
||||
.getRawMany();
|
||||
@@ -856,7 +857,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
.addSelect("count(1)", "count")
|
||||
.where({
|
||||
userId: param.userId,
|
||||
projectId: param.projectId
|
||||
projectId: param.projectId,
|
||||
isTemplate: false
|
||||
})
|
||||
.groupBy("disabled")
|
||||
.getRawMany();
|
||||
@@ -880,7 +882,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
where: {
|
||||
userId,
|
||||
disabled: false,
|
||||
projectId
|
||||
projectId,
|
||||
isTemplate: false
|
||||
}
|
||||
});
|
||||
await this.fillLastVars(list);
|
||||
@@ -902,7 +905,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
.addSelect("COUNT(1) AS count")
|
||||
.where({
|
||||
// 0点
|
||||
createTime: MoreThan(todayEnd.add(-param.days, "day").toDate())
|
||||
createTime: MoreThan(todayEnd.add(-param.days, "day").toDate()),
|
||||
isTemplate: false
|
||||
})
|
||||
.groupBy("date")
|
||||
.getRawMany();
|
||||
|
||||
Reference in New Issue
Block a user