Spaces:
Running
Running
Commit ·
8cdcc3a
1
Parent(s): 5b515c5
Fix: Check user email first in GetToken to prevent unique key violation in SQLite
Browse files30 unmodified lines3132333435363738394041424344454647484930 unmodified lines[HttpGet("token")]public async Task<IActionResult> GetToken(){var userId = Guid.Parse("33d1ae31-bf51-4b12-89d0-8e574e7916ab");var user = await _userRepo.GetByIdAsync(userId);if (user == null){user = new User{Id = userId,Email = "dan9228335@gmail.com",DisplayName = "Dodikuser",PasswordHash = "",CreatedAt = DateTime.UtcNow};await _userRepo.CreateAsync(user);}var token = _tokenService.CreateToken(user);return Ok(new { token });30 unmodified lines313233343536373839404142434445464748495051525354555657585930 unmodified lines[HttpGet("token")]public async Task<IActionResult> GetToken(){// First check if the user exists by email to prevent Unique Index violationsvar user = await _userRepo.GetByEmailAsync("dan9228335@gmail.com");if (user == null){var userId = Guid.Parse("33d1ae31-bf51-4b12-89d0-8e574e7916ab");// Check if the hardcoded ID is somehow already in usevar existingById = await _userRepo.GetByIdAsync(userId);if (existingById != null){user = existingById;}else{user = new User{Id = userId,Email = "dan9228335@gmail.com",DisplayName = "Dodikuser",PasswordHash = "",CreatedAt = DateTime.UtcNow};await _userRepo.CreateAsync(user);}}var token = _tokenService.CreateToken(user);return Ok(new { token });
FlowAPI/Controllers/AgentCanvasController.cs+20-10