This commit is contained in:
AdisakKanthawilang 2024-11-20 15:05:18 +07:00
parent be2afbde3a
commit 854785434f
2 changed files with 27 additions and 30 deletions

View file

@ -1874,9 +1874,9 @@ export class ProfileController extends Controller {
} }
/** /**
* API Email * API Email
* *
* @summary Email * @summary Email
* *
*/ */
@Post("send-verify-email") @Post("send-verify-email")
@ -1889,30 +1889,29 @@ export class ProfileController extends Controller {
subject: string; subject: string;
} }
) { ) {
const profile = await this.profileRepo.findOne({
where:{ const profile = await this.profileRepo.findOne({
id: body.profileId, where:{
email: body.profileId id: body.profileId,
email: body.email
} }
}); });
const jwt = require('jsonwebtoken');
const token = jwt.sign({email_id: body.email}, "Stack", {expiresIn: '24h'});
console.log("[token]",token);
const link = process.env.API_URL + "/" + token;
const detail = null;
await new CallAPI() await new CallAPI()
.PostData(req, "/profile/gen-link-verify-email", { .PostData(req, "/placement/notisend-mail", {
body: body.email, subject: body.subject,
body: detail,
Email: body.email,
}) })
.catch((error) => { .catch((error) => {
console.error("Error calling API:", error); console.error("Error calling API:", error);
}); });
// const detail = null;
// await new CallAPI()
// .PostData(req, "/placement/notisend-mail", {
// subject: body.subject,
// body: detail,
// Email: body.email,
// })
// .catch((error) => {
// console.error("Error calling API:", error);
// });
} }
/** /**
@ -1928,14 +1927,12 @@ export class ProfileController extends Controller {
email: string; email: string;
}, },
) { ) {
// var uuid = require('node-uuid'); const profile = await this.profileRepo.findOne({
// var timeBasedID = uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a' where:{
// var randomID = uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1' id: body.profileId,
// var url = 'www.privatebox.de/' + randomID; // or + timeBasedID email: body.email
var jwt = require('jsonwebtoken'); }
var token = jwt.sign({email_id: body.email}, "Stack", {expiresIn: '24h'}); });
console.log("[token]",token);
} }
@ -7970,7 +7967,7 @@ export class ProfileController extends Controller {
Object.assign(profile, body); Object.assign(profile, body);
Object.assign(history, { ...profile, id: undefined }); Object.assign(history, { ...profile, id: undefined });
profile.emailVerify = "NOT_VERIFIED"; profile.statusEmail = "NOT_VERIFIED";
profile.lastUpdateUserId = request.user.sub; profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name; profile.lastUpdateFullName = request.user.name;
profile.lastUpdatedAt = new Date(); profile.lastUpdatedAt = new Date();

View file

@ -127,7 +127,7 @@ export class Profile extends EntityBase {
comment: "สถานะอีเมล", //VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน comment: "สถานะอีเมล", //VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน
default: null, default: null,
}) })
emailVerify: string; statusEmail: string;
@Column({ @Column({
nullable: true, nullable: true,