improve social modes for discordbot crawler.

This commit is contained in:
41666 2019-03-21 07:57:56 -05:00
parent cd70c58cc9
commit 8dd759d78c
5 changed files with 44 additions and 5 deletions

View file

@ -146,8 +146,14 @@ export default (R: Router, $: AppContext) => {
})
R.get('/magic/:challenge', async (ctx: Context) => {
if (ctx.request.headers['user-agent'].includes('Discordbot')) {
return $.ui.render(ctx.req, ctx.res, '/_internal/_discordbot/_magic', {})
}
const { challenge } = ((ctx.params: any): { challenge: string })
const chall = await $.auth.fetchDMChallenge({ magic: challenge })
// log.notice('magic user agent', { ua: ctx.request.headers['User-Agent'] })
if (chall == null) {
log.warn('bad magic', challenge)
return ctx.redirect('/auth/expired')