blob: 868f95783ead00965dffe84521f6c4a1bc68c0b5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import dbConnect from 'configs/dbConnect'
import withSession from 'hocs/withSession'
import User from 'models/User'
export default withSession(async (req, res) => {
await dbConnect()
switch (req.method) {
case 'POST':
try {
if (req.body.theme && req.body.language) {
const user = await User.saveSettings(req.body)
req.session.set('user', user)
await req.session.save()
res.status(200).json(user)
}
} catch (error) {
res.status(400).send()
}
break
default:
res.status(400).send()
break
}
})
|