fix username validation
This commit is contained in:
parent
a24f0650d1
commit
3c98987678
@ -98,7 +98,7 @@ public class ParteyUserTagManager {
|
||||
*/
|
||||
public List<ParteyUserTag> getAllForUsername(String username) {
|
||||
return Lists.newArrayList(
|
||||
parteyUserTagRepository.findAll(qParteyUserTag.username.eq(username)));
|
||||
parteyUserTagRepository.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +122,7 @@ public class ParteyUserTagManager {
|
||||
|
||||
BooleanBuilder query = new BooleanBuilder();
|
||||
|
||||
query.and(qParteyUserTag.username.eq(username));
|
||||
query.and(qParteyUserTag.username.equalsIgnoreCase(username));
|
||||
query.and(qParteyUserTag.expires.isNull().or(qParteyUserTag.expires.after(Instant.now())));
|
||||
|
||||
if (!upcoming) {
|
||||
@ -160,7 +160,7 @@ public class ParteyUserTagManager {
|
||||
*/
|
||||
public void deleteAllForTarget(String username) {
|
||||
parteyUserTagRepository
|
||||
.deleteAll(parteyUserTagRepository.findAll(qParteyUserTag.username.eq(username)));
|
||||
.deleteAll(parteyUserTagRepository.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ public class UserTagManagementController extends BaseController {
|
||||
@RequestParam("desc") Optional<Boolean> descParameter) {
|
||||
|
||||
Page<ParteyUserTag> page = parteyUserTagManager.getAll(pageParameter.orElse(0),
|
||||
sizeParameter.orElse(10), sortParameter.orElse("username"), descParameter.orElse(false));
|
||||
sizeParameter.orElse(10), sortParameter.orElse("username"),
|
||||
descParameter.orElse(false));
|
||||
|
||||
return page;
|
||||
}
|
||||
@ -93,7 +94,7 @@ public class UserTagManagementController extends BaseController {
|
||||
User user = userManager.getByUsername(username);
|
||||
|
||||
if (user == null) {
|
||||
throw new EntityResponseStatusException(HttpStatus.NO_CONTENT);
|
||||
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
return parteyUserTagManager.getNonExpiredForUsername(username);
|
||||
@ -112,7 +113,7 @@ public class UserTagManagementController extends BaseController {
|
||||
User user = userManager.getByUsername(username);
|
||||
|
||||
if (user == null) {
|
||||
throw new EntityResponseStatusException(HttpStatus.NO_CONTENT);
|
||||
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
return parteyUserTagManager.getNonExpiredForUsername(username, true);
|
||||
@ -127,6 +128,11 @@ public class UserTagManagementController extends BaseController {
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@PostMapping
|
||||
public ParteyUserTag createOrUpdateParteyUserTag(@RequestBody ParteyUserTag parteyUserTag) {
|
||||
User user = userManager.getByUsername(parteyUserTag.getUsername());
|
||||
if (user == null) {
|
||||
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
return parteyUserTagManager.save(parteyUserTag);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user