From 854785434feb4b4d406fefafd812216b80e42779 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 20 Nov 2024 15:05:18 +0700 Subject: [PATCH] fix --- src/controllers/ProfileController.ts | 55 +++++++++++++--------------- src/entities/Profile.ts | 2 +- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 60aff937..ce0483f7 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1874,9 +1874,9 @@ export class ProfileController extends Controller { } /** - * API ยืนยัน Email + * API ส่งลิงค์ยืนยัน Email * - * @summary ยืนยัน Email + * @summary ส่งลิงค์ยืนยัน Email * */ @Post("send-verify-email") @@ -1889,30 +1889,29 @@ export class ProfileController extends Controller { subject: string; } ) { - const profile = await this.profileRepo.findOne({ - where:{ - id: body.profileId, - email: body.profileId + + const profile = await this.profileRepo.findOne({ + where:{ + 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() - .PostData(req, "/profile/gen-link-verify-email", { - body: body.email, + .PostData(req, "/placement/notisend-mail", { + subject: body.subject, + body: detail, + Email: body.email, }) .catch((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; }, ) { - // var uuid = require('node-uuid'); - // var timeBasedID = uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a' - // var randomID = uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1' - // var url = 'www.privatebox.de/' + randomID; // or + timeBasedID - var jwt = require('jsonwebtoken'); - var token = jwt.sign({email_id: body.email}, "Stack", {expiresIn: '24h'}); - console.log("[token]",token); - + const profile = await this.profileRepo.findOne({ + where:{ + id: body.profileId, + email: body.email + } + }); } @@ -7970,7 +7967,7 @@ export class ProfileController extends Controller { Object.assign(profile, body); Object.assign(history, { ...profile, id: undefined }); - profile.emailVerify = "NOT_VERIFIED"; + profile.statusEmail = "NOT_VERIFIED"; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; profile.lastUpdatedAt = new Date(); diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index 96d8672b..bff07fcd 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -127,7 +127,7 @@ export class Profile extends EntityBase { comment: "สถานะอีเมล", //VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน default: null, }) - emailVerify: string; + statusEmail: string; @Column({ nullable: true,