注册加锁

This commit is contained in:
mtvpls
2025-12-24 00:55:37 +08:00
parent bc8b9515a8
commit 3112e99395
3 changed files with 170 additions and 77 deletions
+8
View File
@@ -252,6 +252,14 @@ export class UpstashRedisStorage implements IStorage {
oidcSub?: string,
enabledApis?: string[]
): Promise<void> {
// 先检查用户是否已存在(原子性检查)
const exists = await withRetry(() =>
this.client.exists(this.userInfoKey(userName))
);
if (exists === 1) {
throw new Error('用户已存在');
}
const hashedPassword = await this.hashPassword(password);
const createdAt = Date.now();