no message
This commit is contained in:
parent
9991b3c8ce
commit
d220430325
4 changed files with 62 additions and 44 deletions
|
|
@ -1875,22 +1875,26 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess(profile.id);
|
||||
}
|
||||
|
||||
async sendVerifyEmail(
|
||||
@Request() req:RequestWithUser,
|
||||
@Body()
|
||||
body: {
|
||||
async sendVerifyEmail(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body()
|
||||
body: {
|
||||
profileId: string;
|
||||
email: string;
|
||||
subject: string;
|
||||
}
|
||||
) {
|
||||
const jwt = require('jsonwebtoken');
|
||||
const token = jwt.sign({email_id: body.email, profileId: body.profileId}, process.env.AUTH_ACCOUNT_SECRET, {expiresIn: '5m'});
|
||||
// console.log("[token]",token);
|
||||
const link = process.env.URL + "/verifyemail/" + token;
|
||||
// console.log("[link]",link);
|
||||
email: string;
|
||||
subject: string;
|
||||
},
|
||||
) {
|
||||
const jwt = require("jsonwebtoken");
|
||||
const token = jwt.sign(
|
||||
{ email_id: body.email, profileId: body.profileId },
|
||||
process.env.AUTH_ACCOUNT_SECRET,
|
||||
{ expiresIn: "5m" },
|
||||
);
|
||||
// console.log("[token]",token);
|
||||
const link = process.env.URL + "/verifyemail/" + token;
|
||||
// console.log("[link]",link);
|
||||
|
||||
await new CallAPI()
|
||||
await new CallAPI()
|
||||
.PostData(req, "/placement/noti/send-mail", {
|
||||
subject: body.subject,
|
||||
body: link,
|
||||
|
|
@ -1898,42 +1902,39 @@ export class ProfileController extends Controller {
|
|||
})
|
||||
.catch((error) => {
|
||||
console.error("Error calling API:", error);
|
||||
});
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
});
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ยืนยัน Email
|
||||
*
|
||||
* @summary ยืนยัน Email
|
||||
*
|
||||
*/
|
||||
@Post("verify-email")
|
||||
async genLinkVerifyEmail(
|
||||
@Body() body:{
|
||||
token: string;
|
||||
},
|
||||
) {
|
||||
const jwt = require('jsonwebtoken');
|
||||
@Post("verify-email")
|
||||
async genLinkVerifyEmail(@Body() body: { token: string }) {
|
||||
const jwt = require("jsonwebtoken");
|
||||
const secretKey = process.env.AUTH_ACCOUNT_SECRET || "defaultSecretKey";
|
||||
const decodedToken = jwt.verify(body.token, secretKey);
|
||||
// console.log("[email]",decodedToken);
|
||||
// console.log("[1]",decodedToken.email_id);
|
||||
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where:{
|
||||
id: decodedToken.profileId,
|
||||
email: decodedToken.email_id,
|
||||
}
|
||||
});
|
||||
if(!profile){ throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");}
|
||||
|
||||
Object.assign(profile, body);
|
||||
profile.statusEmail = "VERIFIED";
|
||||
await this.profileRepo.save(profile)
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: {
|
||||
id: decodedToken.profileId,
|
||||
email: decodedToken.email_id,
|
||||
},
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Object.assign(profile, body);
|
||||
profile.statusEmail = "VERIFIED";
|
||||
await this.profileRepo.save(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่ง คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป
|
||||
*
|
||||
|
|
@ -4509,7 +4510,11 @@ export class ProfileController extends Controller {
|
|||
},
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
if (request.user.role.includes("SUPER_ADMIN")) {
|
||||
return new HttpSuccess(null);
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
}
|
||||
|
||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||
|
|
@ -7984,8 +7989,8 @@ export class ProfileController extends Controller {
|
|||
profileId: profile.id,
|
||||
email: body.email,
|
||||
subject: "ยืนยันอีเมล",
|
||||
}
|
||||
this.sendVerifyEmail(request,verifyemailBody);
|
||||
};
|
||||
this.sendVerifyEmail(request, verifyemailBody);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1854,7 +1854,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
},
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
if (request.user.role.includes("SUPER_ADMIN")) {
|
||||
return new HttpSuccess(null);
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
}
|
||||
|
||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||
|
|
|
|||
|
|
@ -1755,7 +1755,11 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
},
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
if (request.user.role.includes("SUPER_ADMIN")) {
|
||||
return new HttpSuccess(null);
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
}
|
||||
|
||||
let orgRevisionPublish: any = await this.orgRevisionRepo
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ export class KeycloakController extends Controller {
|
|||
profile.keycloak = null_;
|
||||
profile.roleKeycloaks = [];
|
||||
await this.profileRepo.save(profile);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
// @Security("bearerAuth", ["system", "admin"])
|
||||
|
|
@ -280,6 +281,7 @@ export class KeycloakController extends Controller {
|
|||
);
|
||||
|
||||
if (!result) throw new Error("Failed. Cannot set user's role.");
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{userId}/role/{roleId}")
|
||||
|
|
@ -310,6 +312,7 @@ export class KeycloakController extends Controller {
|
|||
list.filter((v) => roleId === v.id),
|
||||
);
|
||||
if (!result) throw new Error("Failed. Cannot remove user's role.");
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/*@Get("user")
|
||||
|
|
@ -517,6 +520,7 @@ export class KeycloakController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("profile.citizenId", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
@ -546,6 +550,7 @@ export class KeycloakController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("profileEmployee.citizenId", "ASC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue