[user] mastodon login - don't reuse keys, looks like it's not working

This commit is contained in:
Andrea Vos 2022-07-06 17:46:16 +02:00
parent d9870c12c1
commit 38026537e7

View File

@ -37,9 +37,10 @@ const mastodonGetOAuthKeys = async (db, instance) => {
WHERE instance = ${instance} WHERE instance = ${instance}
AND provider = 'mastodon' AND provider = 'mastodon'
`); `);
if (existingKeys) { // TODO figure out why it doesn't work
return existingKeys; // if (existingKeys) {
} // return existingKeys;
// }
const keys = await fetch(`https://${instance}/api/v1/apps`, { const keys = await fetch(`https://${instance}/api/v1/apps`, {
method: 'POST', method: 'POST',
body: new URLSearchParams({ body: new URLSearchParams({
@ -54,10 +55,13 @@ const mastodonGetOAuthKeys = async (db, instance) => {
}, },
}).then(res => res.json()); }).then(res => res.json());
assert(keys.client_id && keys.client_secret && !keys.error); assert(keys.client_id && keys.client_secret && !keys.error);
db.get(SQL` // TODO figure out why it doesn't work
INSERT INTO oauth_keys (instance, provider, client_id, client_secret) if (existingKeys) {
VALUES (${instance}, 'mastodon', ${keys.client_id}, ${keys.client_secret}) db.get(SQL`
`); INSERT INTO oauth_keys (instance, provider, client_id, client_secret)
VALUES (${instance}, 'mastodon', ${keys.client_id}, ${keys.client_secret})
`);
}
return keys; return keys;
}; };