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

View File

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

View File

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