1
0
Fork 0
mirror of synced 2024-08-04 04:41:37 +12:00
budibase/packages/server/middleware/routeHandlers/authenticate.js
2020-03-10 10:05:09 +00:00

16 lines
406 B
JavaScript

const StatusCodes = require("../../utilities/statusCodes")
module.exports = async ctx => {
const user = await ctx.master.authenticate(
ctx.sessionId,
ctx.params.appname,
ctx.request.body.username,
ctx.request.body.password
)
if (!user) {
ctx.throw(StatusCodes.UNAUTHORIZED, "invalid username or password")
}
ctx.body = user.user_json
ctx.response.status = StatusCodes.OK
}