feat(server): implemented login via ARL
This commit is contained in:
parent
7caccd048e
commit
2dc9ab66d4
@ -1,3 +1,3 @@
|
||||
import { ApiHandler } from '../../../types'
|
||||
import loginArl from './login-arl'
|
||||
|
||||
export default [] as ApiHandler[]
|
||||
export default [loginArl]
|
||||
|
39
server/src/routes/api/post/login-arl.ts
Normal file
39
server/src/routes/api/post/login-arl.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { RequestHandler } from 'express'
|
||||
import { ApiHandler } from '../../../types'
|
||||
import { dz } from '../../../main'
|
||||
|
||||
export interface RawLoginArlQuery {
|
||||
arl: string
|
||||
child?: number
|
||||
}
|
||||
|
||||
const path: ApiHandler['path'] = '/login-arl/'
|
||||
|
||||
const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, next) => {
|
||||
if (!req.query) {
|
||||
res.status(400).send()
|
||||
return next()
|
||||
}
|
||||
|
||||
if (!req.query.arl) {
|
||||
res.status(400).send()
|
||||
return next()
|
||||
}
|
||||
|
||||
const loginParams: (string | number)[] = [req.query.arl]
|
||||
|
||||
// TODO Handle the child === 0 case, don't want to rely on the login_via_arl default param (it may change in the
|
||||
// future)
|
||||
if (req.query.child) {
|
||||
loginParams.push(req.query.child)
|
||||
}
|
||||
|
||||
const response = await dz.login_via_arl(...loginParams)
|
||||
|
||||
res.status(200).send(response)
|
||||
next()
|
||||
}
|
||||
|
||||
const apiHandler = { path, handler }
|
||||
|
||||
export default apiHandler
|
Loading…
Reference in New Issue
Block a user