mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-15 01:49:10 +00:00
finish rudimentary auth flow
This commit is contained in:
parent
90f302c103
commit
cfc623b228
10 changed files with 101 additions and 15 deletions
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue