diff --git a/src/actions.ts b/src/actions.ts index ea3f859..fc95a04 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -744,14 +744,18 @@ export const actions: { [k: string]: QueryHandler } = { await tables.oauthTokens.delete(existing.id); return { success: false }; } else { - return { success: existing.id }; + return { success: existing.id, user: this.user.id }; } } const id = crypto.randomBytes(16).toString('hex'); await tables.oauthTokens.insert({ id, owner: this.user.id, client: clientInfo.id, time: Date.now(), }); - return { success: id, expires: Date.now() + OAUTH_TOKEN_TIME }; + return { + success: id, + expires: Date.now() + OAUTH_TOKEN_TIME, + user: this.user.id, + }; }, async 'oauth/api/refreshtoken'(params) { @@ -884,6 +888,11 @@ export const actions: { [k: string]: QueryHandler } = { )`WHERE teamid = ${teamid}`; const owns = data?.ownerid === this.user.id; if (!data || (owns ? false : (data.private && (password !== toID(data.private))))) { + if (!full) { + void fs.appendFile(`./config/teams.log`, JSON.stringify({ + teamid, user: this.user.id, date: Date.now(), + })); + } return { team: null }; } if ('views' in data && this.user.id !== data.ownerid) { diff --git a/src/public/oauth-authorize.html b/src/public/oauth-authorize.html index 38865d3..b8f6efd 100644 --- a/src/public/oauth-authorize.html +++ b/src/public/oauth-authorize.html @@ -87,7 +87,7 @@ }); } var redirect = new URL(params.get('redirect_uri')); - redirect.search = new URLSearchParams({assertion: data.data, token: token}); + redirect.search = new URLSearchParams({assertion: data.data, token: token, user: data.user}); location.replace(redirect); })); } diff --git a/src/server.ts b/src/server.ts index c336172..468205b 100644 --- a/src/server.ts +++ b/src/server.ts @@ -213,7 +213,7 @@ export class ActionContext { // account for shit like ::ffff:127.0.0.1 const num = IPTools.ipToNumber(ip) || 0; return ( - ip === '::ffff:127.0.0.1' || + ip === '::ffff:127.0.0.1' || ip === '127.0.0.1' || Config.trustedproxies.some(f => IPTools.checkPattern(f, ip)) || IPTools.privateRelayIPs.some(f => f.minIP <= num && num <= f.maxIP) );