finish rudimentary auth flow

This commit is contained in:
41666 2017-12-10 05:26:56 -06:00
parent 90f302c103
commit cfc623b228
10 changed files with 101 additions and 15 deletions

View file

@ -51,6 +51,10 @@ module.exports = (R, $) => {
})
R.get('/api/auth/redirect', ctx => {
ctx.redirect($.discord.getAuthUrl())
ctx.body = { url: $.discord.getAuthUrl() }
})
R.post('/api/auth/logout', ctx => {
ctx.session = null
})
}

View file

@ -92,6 +92,10 @@ class DiscordService extends Service {
async getUser (authToken) {
const url = 'https://discordapp.com/api/v6/users/@me'
try {
if (authToken == null || authToken === '') {
throw new Error('not logged in')
}
const rsp =
await superagent
.get(url)