mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-22 09:11:59 -07:00
29 lines
595 B
JavaScript
29 lines
595 B
JavaScript
import User from '../../models/users'
|
|
import config from '../../../config'
|
|
import jwt from 'jsonwebtoken'
|
|
|
|
export async function createUser(ctx) {
|
|
const user = new User(ctx.request.body.user)
|
|
try {
|
|
await user.save()
|
|
const token = jwt.sign({ id: user.id }, config.token)
|
|
|
|
const response = user.toJSON()
|
|
|
|
delete response.password
|
|
delete response.salt
|
|
|
|
ctx.body = {
|
|
user: response,
|
|
token
|
|
}
|
|
} catch (err) {
|
|
ctx.throw(422, err)
|
|
}
|
|
}
|
|
|
|
export async function getUsers (ctx) {
|
|
const users = await User.find({}, '-password -salt')
|
|
ctx.body = users
|
|
}
|