mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 10:19:10 +00:00
backend/auth: redo OAuth flow and "finish" DM auth flow
This commit is contained in:
parent
1b8d90b24b
commit
ff67bc3f1b
4 changed files with 167 additions and 12 deletions
16
rpc/auth.js
Normal file
16
rpc/auth.js
Normal 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
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue