fixed a non-404 responce in the case when the customer is not found
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.chrisrichardson.eventstore.javaexamples.banking.commonauth;
|
||||
|
||||
import net.chrisrichardson.eventstore.javaexamples.banking.web.customers.queryside.common.QuerySideCustomer;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.dao.support.DataAccessUtils;
|
||||
|
||||
/**
|
||||
@@ -14,10 +15,18 @@ public class CustomerAuthService {
|
||||
}
|
||||
|
||||
public QuerySideCustomer findByEmail(String email) {
|
||||
return DataAccessUtils.uniqueResult(customerAuthRepository.findByEmail(email));
|
||||
QuerySideCustomer result = DataAccessUtils.uniqueResult(customerAuthRepository.findByEmail(email));
|
||||
if (result==null)
|
||||
throw new EmptyResultDataAccessException(1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public QuerySideCustomer findByEmailAndPassword(String email, String password) {
|
||||
return DataAccessUtils.uniqueResult(customerAuthRepository.findByEmailAndPassword(email, password));
|
||||
QuerySideCustomer result = DataAccessUtils.uniqueResult(customerAuthRepository.findByEmailAndPassword(email, password));
|
||||
if (result==null)
|
||||
throw new EmptyResultDataAccessException(1);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user