Compare commits

..

No commits in common. '5ecff037dcee798e6768bfc0d38558beb559d440' and 'c8185bb5c0409e8e827b7a473f0c3a86c3dc6ca2' have entirely different histories.

@ -27,9 +27,7 @@ export const applyAuthRoutes = (router) => {
const tokens = (await axios.post('https://accounts.spotify.com/api/token', params, config))?.data;
const newClient = await Client.create({
refreshToken: true,
retryOnRateLimit: true,
const client = await Client.create({
token: {
clientID: store.clientID,
clientSecret: store.clientSecret,
@ -37,13 +35,9 @@ export const applyAuthRoutes = (router) => {
refreshToken: tokens.refresh_token,
},
});
const player = new Player(newClient);
const player = new Player(client);
const accessToken = randomString(64);
const user = store.users.find(({ client }) => client.user.id === newClient.user.id);
if (user) {
user.client = newClient;
}
store.users.push({ client: newClient, player, accessToken, listeners: [], role: 'none' });
store.users.push({ client, player, accessToken, listeners: [], role: 'none' });
res.status(200);
res.send({ message: 'authorized', accessToken });
} catch (e) {

@ -1,11 +0,0 @@
import { store } from "../store.mjs";
export const auth = (req, res, next) => {
const accessToken = req.headers['access-token'];
res.locals.user = store.users.find(user => user.accessToken === accessToken);
if (!res.locals.user) {
res.status(401);
res.send({ message: 'unauthorized' });
}
else next();
};

@ -1,12 +1,12 @@
{
"name": "spot2gether",
"version": "0.1.0",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "spot2gether",
"version": "0.1.0",
"version": "1.0.0",
"dependencies": {
"axios": "^0.27.2",
"express": "^4.18.1",

@ -1 +1 @@
Subproject commit e4de1997a3c34a9fb96136e82446ee926104c3d0
Subproject commit a86bd04da25c3715e7853cd1158b7e4929eacad4
Loading…
Cancel
Save