let express = require('express')
let router = express.Router()
const auth = require('../lib/authUserInfo')
const Errors = require('../lib/errors')
let { User, Ban } = require('../models')

router.get('/', auth, auth, async(req, res, next) => {
    try {
        let queryObj = {
            attributes: {exclude: ['hash', 'currency2', 'emailToken', 'passwordResetToken', 'deleteCode', 'deleteEnabled', 'jwtOffset']},
            where: {username: req.userData.username}
        }
         let user = await User.findOne(queryObj)
         if(!user) {
             res.status(200)
             res.json({
                 errors: ["Please login to use this endpoint, idk what you expected"]
             })
         }
         res.status(200)
         res.json(user.toJSON())

    } catch (err) { next(err) }
})

module.exports = router
