This commit is contained in:
AdisakKanthawilang 2024-11-21 17:32:31 +07:00
parent 522de9a7da
commit d01ca5f061
2 changed files with 30 additions and 29 deletions

View file

@ -11,6 +11,7 @@ import { calculateRetireDate } from "../interfaces/utils";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import { Profile } from "../entities/Profile";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import HttpStatus from "../interfaces/http-status";
@Route("api/v1/org/unauthorize")
@Tags("OrganizationUnauthorize")
@ -1123,4 +1124,33 @@ export class OrganizationUnauthorizeController extends Controller {
return new HttpSuccess(mapProfile);
}
/**
* API Email
*
* @summary Email
*
*/
@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);
}
}

View file

@ -1902,35 +1902,6 @@ export class ProfileController extends Controller {
return new HttpSuccess();
}
/**
* API Email
*
* @summary Email
*
*/
@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);
}
/**
* API
*