Only store Discord user ID

This commit is contained in:
Jonathan Barrow 2022-07-15 20:47:56 -04:00
parent da9b2f66fe
commit 0caa1b9b66
3 changed files with 6 additions and 14 deletions

View File

@ -183,7 +183,7 @@ async function addUserConnection(pnid, data, type) {
}
async function addUserConnectionDiscord(pnid, data) {
if (!data.id || !data.access_token || !data.refresh_token) {
if (!data.id) {
return {
app: 'api',
status: 400,
@ -213,9 +213,7 @@ async function removeUserConnection(pnid, type) {
async function removeUserConnectionDiscord(pnid) {
await PNID.updateOne({ pid: pnid.get('pid') }, {
$set: {
'connections.discord.id': '',
'connections.discord.access_token': '',
'connections.discord.refresh_token': ''
'connections.discord.id': ''
}
});

View File

@ -100,9 +100,7 @@ const PNIDSchema = new Schema({
},
connections: {
discord: {
id: String,
access_token: String,
refresh_token: String,
id: String
}
}
});

View File

@ -1,5 +1,5 @@
const router = require('express').Router();
const { PNID } = require('./models/pnid');
const { PNID } = require('../../../../models/pnid');
/**
* [GET]
@ -43,9 +43,7 @@ router.get('/', async (request, response) => {
},
connections: {
discord: {
id: pnid.get('connections.discord.id'),
access_token: pnid.get('connections.discord.access_token'),
refresh_token: pnid.get('connections.discord.refresh_token'),
id: pnid.get('connections.discord.id')
}
}
});
@ -99,9 +97,7 @@ router.post('/', async (request, response) => {
},
connections: {
discord: {
id: pnid.get('connections.discord.id'),
access_token: pnid.get('connections.discord.access_token'),
refresh_token: pnid.get('connections.discord.refresh_token'),
id: pnid.get('connections.discord.id')
}
}
});