Skip to content
Snippets Groups Projects
Commit 05a49703 authored by Dominik František Bučík's avatar Dominik František Bučík
Browse files

chore: merge branch 'fix_no_code' into 'main'

fix: :bug: Throw correct error when no auth_code found

See merge request !386
parents d3cdbe83 1105142f
Branches
Tags
1 merge request!386fix: 🐛 Throw correct error when no auth_code found
Pipeline #412409 passed
......@@ -29,6 +29,7 @@ import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import java.util.Collection;
......@@ -67,7 +68,11 @@ public class JpaAuthorizationCodeRepository implements AuthorizationCodeReposito
AuthorizationCodeEntity.QUERY_BY_VALUE, AuthorizationCodeEntity.class
);
query.setParameter(AuthorizationCodeEntity.PARAM_CODE, code);
return query.getSingleResult();
try {
return query.getSingleResult();
} catch (NoResultException ex) {
return null;
}
}
/* (non-Javadoc)
......
......@@ -100,7 +100,7 @@ public class DefaultOAuth2AuthorizationCodeService implements AuthorizationCodeS
AuthorizationCodeEntity result = repository.getByCode(code);
if (result == null) {
throw new InvalidGrantException("JpaAuthorizationCodeRepository: no authorization code found for value " + code);
throw new InvalidGrantException("No authorization code found for value " + code);
}
OAuth2Authentication auth = result.getAuthenticationHolder().getAuthentication();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment