mirror of
https://github.com/kou029w/_.git
synced 2025-01-31 14:28:04 +00:00
14 lines
394 B
TypeScript
14 lines
394 B
TypeScript
import { defineController } from './$relay'
|
|
import { validateUser, createToken, deleteToken } from '$/service/user'
|
|
|
|
export default defineController(() => ({
|
|
post: ({ body }) =>
|
|
validateUser(body.id, body.pass)
|
|
? { status: 201, body: { token: createToken() } }
|
|
: { status: 401 },
|
|
|
|
delete: ({ headers }) => {
|
|
deleteToken(headers.token)
|
|
return { status: 204 }
|
|
}
|
|
}))
|