Skip to content

Commit

Permalink
Fix typo and clean up some other bits
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Oct 16, 2022
1 parent f7a2c07 commit 2229750
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions server/src/action-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ async function createRecord(Cache, tableName, records) {
newRecords.forEach(record => {
Cache.set(cleanID(record.id), deAirtable(record.fields), { eager: true });
});
console.log(newRecords.length);
console.log(newRecords);
// console.log(newRecords.length);
// console.log(newRecords);
} catch (e) {
console.error("Airtable create failed", e);
return { error: true, errorMessage: e.message };
Expand Down
14 changes: 9 additions & 5 deletions server/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ module.exports = ({ app, cors, Cache, io }) => {
if (!TwitchEnvSet) return res.status(503).send({ error: true, message: "Twitch authentication is disabled on the server." });
let state = createState();
states[state] = req.params.scopes;
res.redirect(`https://id.twitch.tv/oauth2/authorize?client_id=${process.env.TWITCH_CLIENT_ID}&redirect_uri=${process.env.TWITCH_REDIRECT_URI}&response_type=code&scope=${req.params.scopes}&force_verify=true`);
res.redirect(`https://id.twitch.tv/oauth2/authorize?client_id=${process.env.TWITCH_CLIENT_ID}&redirect_uri=${process.env.TWITCH_REDIRECT_URI}&response_type=code&scope=${req.params.scopes}&force_verify=true&state=${state}`);
});


Expand All @@ -332,25 +332,29 @@ module.exports = ({ app, cors, Cache, io }) => {
if (existingChannel) {
airtableResponse = await updateRecord(Cache, "Channels", existingChannel.id, {
"Twitch Refresh Token": tokenInfo.accessToken,
"Twitch Scopes": tokenInfo.scopes.join(" "),
"Twitch Scopes": tokenInfo.scope.join(" "),
"Channel ID": tokenInfo.userId,
"Name": tokenInfo.userName
});

} else {
airtableResponse = await createRecord(Cache, "Channels", [{
"Twitch Refresh Token": tokenInfo.accessToken,
"Twitch Scopes": tokenInfo.scopes.join(" "),
"Twitch Scopes": tokenInfo.scope.join(" "),
"Channel ID": tokenInfo.userId,
"Name": tokenInfo.userName
}]);
}

// console.log(airtableResponse);

return res.send("okay thanks");
if (airtableResponse.error) {
return res.status(400).send({ error: true, errorMessage: airtableResponse.errorMessage });
}
return res.send("poggers thanks");
} catch (e) {
console.error("[Twitch Auth] error", e);
res.status(400).send({ error: true, errorMessage: e.message});
res.status(400).send({ error: true, errorMessage: e.message });
}
});

Expand Down
2 changes: 1 addition & 1 deletion website/src/components/website/TwitchAuthScopeSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
value: "channel:manage:predictions channel:read:predictions"
},
{
text: "Title (channel:manage:broadcast)",
text: "Title/Game (channel:manage:broadcast)",
value: "channel:manage:broadcast"
},
{
Expand Down
2 changes: 1 addition & 1 deletion website/src/router/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default [
component: Authenticator
},
{
path: "/twitch-scopes",
path: "/twitch-auth",
component: TwitchAuthScopeSelector
}
]
Expand Down

0 comments on commit 2229750

Please sign in to comment.