deemixer/server/src/routes/api/post/loginEmail.ts
2022-01-13 01:27:08 +01:00

23 lines
594 B
TypeScript

import { ApiHandler } from '../../../types'
import { getAccessToken, getArlFromAccessToken } from '../../../main'
const path = '/loginEmail'
const handler: ApiHandler['handler'] = async (req, res) => {
const { email, password } = req.body
let accessToken = req.body.accessToken
if (!accessToken) {
accessToken = await getAccessToken(email, password)
if (accessToken === 'undefined') accessToken = undefined
}
let arl
if (accessToken) arl = await getArlFromAccessToken(accessToken)
res.send({ accessToken, arl })
}
const apiHandler = { path, handler }
export default apiHandler