Fix: search by email on register
This commit is contained in:
@@ -38,7 +38,8 @@ public interface CredentialRepository extends JpaRepository<Credential, byte[]>
|
||||
@Query("SELECT c FROM Credential c WHERE c.userIdBin = :userIdBin")
|
||||
List<Credential> findByUserId(@Param("userIdBin") byte[] userIdBin);
|
||||
|
||||
List<Credential> findByEmail(String email);
|
||||
@Query("SELECT c FROM Credential c WHERE c.email = :email")
|
||||
List<Credential> findByEmail(@Param("email") String email);
|
||||
|
||||
boolean existsByUsernameAndServiceId(String username, Byte serviceId);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.miarma.backend.core.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -57,9 +58,10 @@ public class AuthService {
|
||||
userIdByUsername = credByUsername.get().getUserId();
|
||||
}
|
||||
|
||||
try {
|
||||
userIdByEmail = credentialService.getByEmail(request.email()).get(0).getUserId();
|
||||
} catch (NotFoundException e) { }
|
||||
List<Credential> accountsByEmail = credentialService.getByEmail(request.email());
|
||||
if (!accountsByEmail.isEmpty()) {
|
||||
userIdByEmail = accountsByEmail.getFirst().getUserId();
|
||||
}
|
||||
|
||||
User user;
|
||||
if (userIdByUsername != null && userIdByEmail != null) {
|
||||
|
||||
@@ -88,8 +88,7 @@ public class CredentialService {
|
||||
}
|
||||
|
||||
public List<Credential> getByEmail(String email) {
|
||||
return credentialRepository.findByEmail(email).stream()
|
||||
.toList();
|
||||
return credentialRepository.findByEmail(email);
|
||||
}
|
||||
|
||||
public Credential getByUserIdAndService(UUID userId, Byte serviceId) {
|
||||
|
||||
Reference in New Issue
Block a user