backend/auth: redo OAuth flow and "finish" DM auth flow

This commit is contained in:
41666 2019-03-19 20:25:38 -05:00
parent 1b8d90b24b
commit ff67bc3f1b
4 changed files with 167 additions and 12 deletions

16
rpc/auth.js Normal file
View file

@ -0,0 +1,16 @@
// @flow
import { type AppContext } from '../Roleypoly'
import { type Context } from 'koa'
export default ($: AppContext) => ({
async checkAuthChallenge (ctx: Context, text: string): Promise<boolean> {
const chall = await $.auth.fetchDMChallenge({ human: text })
if (chall == null) {
return false
}
$.auth.injectSessionFromChallenge(ctx, chall)
$.auth.deleteDMChallenge(chall)
return true
}
})