diff options
author | 2022-05-08 13:05:58 +0100 | |
---|---|---|
committer | 2022-05-08 13:05:58 +0100 | |
commit | 5086e947a995004f8eaf79668493c57051550545 (patch) | |
tree | 23f1881065ef8b533d10ac69421d2d54e605f334 /pages/api | |
parent | ef8d5215e8115ac47d058a667a93b27bc0887a7f (diff) | |
download | my_apps-5086e947a995004f8eaf79668493c57051550545.tar.gz my_apps-5086e947a995004f8eaf79668493c57051550545.tar.bz2 my_apps-5086e947a995004f8eaf79668493c57051550545.zip |
send req as plain text
Diffstat (limited to 'pages/api')
-rw-r--r-- | pages/api/login.js | 3 | ||||
-rw-r--r-- | pages/api/register.js | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/pages/api/login.js b/pages/api/login.js index 5d5dd9c..1e9f816 100644 --- a/pages/api/login.js +++ b/pages/api/login.js @@ -10,7 +10,8 @@ export default withSession(async (req, res) => { switch (method) { case 'POST': try { - const { _id, email, isVerified, noteList, theme, language } = await User.findByCredentials(req.body.email, req.body.password) + const { email, password } = JSON.parse(req.body) + const { _id, isVerified, noteList, theme, language } = await User.findByCredentials(email, password) if (!email) { throw new Error('Something went wrong') } const user = { _id, email, isVerified, isLoggedIn: true, noteList, theme, language } diff --git a/pages/api/register.js b/pages/api/register.js index ba72e53..2c866de 100644 --- a/pages/api/register.js +++ b/pages/api/register.js @@ -15,11 +15,12 @@ export default withSession(async (req, res) => { await session.withTransaction(async () => { const noteList = await NoteList.create({}) - const { _id, email, verificationKey: key, theme, language } = await User.create({ ...req.body, noteList }) + const body = JSON.parse(req.body) + const { _id, email, verificationKey: key, theme, language } = await User.create({ ...body, noteList }) if (!email) { throw new Error('Something went wrong') } - sendMail(req.body.email, subject(language), text(language, key), html(language, key)) + sendMail(body.email, subject(language), text(language, key), html(language, key)) const user = { _id, email, noteList, theme, language, isVerified: false, isLoggedIn: true } req.session.set('user', user) |