mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-15 19:57:07 +08:00
fix: harden authentication and file access security
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// All account mutations in the HTTP service share one queue. In particular,
|
||||
// a login that read old credentials must finish before a password reset revokes
|
||||
// its session, and two initialization requests must not both claim the account.
|
||||
let pending: Promise<unknown> = Promise.resolve();
|
||||
|
||||
export function serializeAuthMutation(
|
||||
_target: object,
|
||||
_key: string,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
const method = descriptor.value;
|
||||
descriptor.value = function (this: unknown, ...args: unknown[]) {
|
||||
const result = pending.then(() => method.apply(this, args));
|
||||
pending = result.catch(() => undefined);
|
||||
return result;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user