update user model

This commit is contained in:
Nikola Petrov 2023-09-23 17:11:24 +02:00
parent 6d18dda99a
commit 5476915b28
4 changed files with 6 additions and 7 deletions

View File

@ -35,13 +35,13 @@ module.exports = {
return res.status(409).json({ message: 'Game already exists' }); return res.status(409).json({ message: 'Game already exists' });
} }
const uri = "https://id.twitch.tv/oauth2/token?client_id=" + userFound.client_id + "&client_secret=" + userFound.client_secret + "&grant_type=client_credentials"; const uri = "https://id.twitch.tv/oauth2/token?client_id=" + userFound.twitch_client_id + "&client_secret=" + userFound.twitch_client_secret + "&grant_type=client_credentials";
var response = await fetch(uri, { method: 'POST' }); var response = await fetch(uri, { method: 'POST' });
var mData = await response.json(); var mData = await response.json();
var mheaders = { var mheaders = {
'Accept': 'application/json', 'Accept': 'application/json',
'Client-ID': userFound.client_id, 'Client-ID': userFound.twitch_client_id,
'Authorization': 'Bearer ' + mData.access_token 'Authorization': 'Bearer ' + mData.access_token
} }

View File

@ -45,7 +45,7 @@ module.exports = {
return res.status(409).json({ message: 'Media already exists' }); return res.status(409).json({ message: 'Media already exists' });
} }
const uri = `http://www.omdbapi.com/?i=${mediaCode}&apikey=${userFound.key}`; const uri = `http://www.omdbapi.com/?i=${mediaCode}&apikey=${userFound.omdb_key}`;
const mJson = await fetch(uri); const mJson = await fetch(uri);
const mData = await mJson.json(); const mData = await mJson.json();

View File

@ -3,9 +3,9 @@ var Schema = mongoose.Schema;
var userSchema = new Schema({ var userSchema = new Schema({
'pass': String, 'pass': String,
'key': String, 'omdb_key': String,
'client_id': String, 'twitch_client_id': String,
'client_secret': String, 'twitch_client_secret': String,
}); });
module.exports = mongoose.model('user', userSchema); module.exports = mongoose.model('user', userSchema);

View File

@ -1,5 +1,4 @@
var express = require('express'); var express = require('express');
const fs = require('fs');
var router = express.Router(); var router = express.Router();
/* GET home page. */ /* GET home page. */