Files
2026-07-26 18:25:37 +09:00

27 lines
804 B
JavaScript

import { Users, UserProfiles } from "../../../models/index.js";
import { publishMainStream } from "../../../services/stream.js";
export default (async (ctx)=>{
const body = ctx.request.body;
const code = body["code"];
const profile = await UserProfiles.findOneByOrFail({
emailVerifyCode: code
});
if (profile != null) {
ctx.body = "Verify succeeded!";
await UserProfiles.update({
userId: profile.userId
}, {
emailVerified: true,
emailVerifyCode: null
});
publishMainStream(profile.userId, "meUpdated", await Users.pack(profile.userId, {
id: profile.userId
}, {
detail: true,
includeSecrets: true
}));
} else {
ctx.throw(404);
}
});