Sync box changes to remote

This commit is contained in:
Mia 2025-08-22 01:50:50 +00:00 committed by Guangcong Luo
parent 7f45fde4f7
commit 0ade3441e3
3 changed files with 13 additions and 4 deletions

View File

@ -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) {

View File

@ -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);
}));
}

View File

@ -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)
);