1
0
Fork 0
mirror of synced 2024-09-09 22:16:26 +12:00
budibase/packages/server/middleware/routeHandlers/authenticate.js

16 lines
406 B
JavaScript
Raw Normal View History

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
}