mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-consumer.git
synced 2026-09-21 16:52:03 -07:00
Lint
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import Router from 'koa-router'
|
||||
import passport from 'koa-passport'
|
||||
import jwt from 'jsonwebtoken'
|
||||
import config from '../../config/config'
|
||||
|
||||
const router = new Router({ prefix: '/auth' })
|
||||
|
||||
router.post('/', async (ctx, next) =>
|
||||
passport.authenticate('local', (user) => {
|
||||
if (!user) {
|
||||
ctx.throw(401)
|
||||
}
|
||||
|
||||
const token = jwt.sign({ id: user.id }, config.tokenSecret)
|
||||
|
||||
const response = user.toJSON()
|
||||
|
||||
delete response.password
|
||||
delete response.salt
|
||||
|
||||
ctx.body = {
|
||||
token,
|
||||
user: response
|
||||
}
|
||||
})(ctx, next)
|
||||
)
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user