Improve UUID generation for user identification
Refactor the `generateDeterministicUUID` function in `server/routes.ts` to use an arrow function syntax and update the UUID generation logic for user identification. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 170e18f0-0f13-4eca-8643-546bba1dd8cc Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/170e18f0-0f13-4eca-8643-546bba1dd8cc/7eNxwas
This commit is contained in:
parent
d91a94675c
commit
18d07fb8eb
BIN
attached_assets/image_1756817337439.png
Normal file
BIN
attached_assets/image_1756817337439.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
@ -862,7 +862,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
try {
|
||||
// Import the generateDeterministicUUID function from replitAuth
|
||||
const { createHash } = await import('crypto');
|
||||
function generateDeterministicUUID(replitId: string): string {
|
||||
const generateDeterministicUUID = (replitId: string): string => {
|
||||
const hash = createHash('sha256').update(`replit_${replitId}`).digest('hex');
|
||||
return [
|
||||
hash.substring(0, 8),
|
||||
@ -871,7 +871,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
(parseInt(hash.substring(16, 17), 16) & 0x3 | 0x8).toString(16) + hash.substring(17, 20),
|
||||
hash.substring(20, 32)
|
||||
].join('-');
|
||||
}
|
||||
};
|
||||
|
||||
const userId = generateDeterministicUUID(req.user.claims.sub);
|
||||
const user = await storage.getUser(userId);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user