aboutsummaryrefslogtreecommitdiffstats
path: root/\
blob: 59db3b6e7e5a88116343d335f0864624a76c66e1 (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
import dbConnect from 'lib/dbConnect'
import withSession from 'lib/withSession'
import User from 'models/User'

export default withSession(async (req, res) => {
  await dbConnect()

  const user = req.session.get('user')

  if (user) {
    const state = await User.state(user._id)

    res.json({
      isLoggedIn: true,
      ...user,
      ...state
    })
  } else {
    res.json({
      isLoggedIn: false,
    })
  }
})