aboutsummaryrefslogtreecommitdiffstats
path: root/pages/api
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/login.js3
-rw-r--r--pages/api/register.js5
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)