mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-07 15:31:00 +08:00
More sanity check changes
This commit is contained in:
parent
9d4a291376
commit
2cf3ff71a6
@ -132,7 +132,9 @@ public class HangarUserController extends HangarComponent {
|
||||
this.actionLogger.user(LogAction.USER_TAGLINE_CHANGED.create(UserContext.of(userTable.getId()), userTable.getTagline(), oldTagline));
|
||||
}
|
||||
|
||||
// @el(userName: String)
|
||||
@Unlocked
|
||||
@CurrentUser("#userName")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@PermissionRequired(NamedPermission.EDIT_OWN_USER_SETTINGS)
|
||||
@PostMapping("/users/{userName}/settings/resetTagline")
|
||||
@ -150,7 +152,9 @@ public class HangarUserController extends HangarComponent {
|
||||
this.actionLogger.user(LogAction.USER_TAGLINE_CHANGED.create(UserContext.of(userTable.getId()), "", oldTagline));
|
||||
}
|
||||
|
||||
// @el(userName: String)
|
||||
@Unlocked
|
||||
@CurrentUser("#userName")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@RateLimit(overdraft = 5, refillTokens = 2)
|
||||
@PermissionRequired(NamedPermission.EDIT_OWN_USER_SETTINGS)
|
||||
|
@ -120,11 +120,7 @@ public class ProjectController extends HangarComponent {
|
||||
@PermissionRequired(type = PermissionType.PROJECT, perms = NamedPermission.EDIT_SUBJECT_SETTINGS, args = "{#author, #slug}")
|
||||
@PostMapping(path = "/project/{author}/{slug}/sponsors", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public void saveProjectSettings(@PathVariable final String author, @PathVariable final String slug, @RequestBody final StringContent content) {
|
||||
final String trimmedContent = content.getContent() != null ? content.getContent().trim() : "";
|
||||
if (trimmedContent.length() > this.config.projects.maxSponsorsLen()) {
|
||||
throw new HangarApiException("page.new.error.maxLength");
|
||||
}
|
||||
this.projectService.saveSponsors(author, slug, trimmedContent);
|
||||
this.projectService.saveSponsors(author, slug, content.getContent());
|
||||
}
|
||||
|
||||
@Unlocked
|
||||
|
@ -102,10 +102,10 @@ public class ProjectFactory extends HangarComponent {
|
||||
public String renameProject(final String author, final String slug, final String newName, final boolean skipNameCheck) {
|
||||
final String compactNewName = StringUtils.compact(newName);
|
||||
final ProjectTable projectTable = this.projectService.getProjectTable(author, slug);
|
||||
final String oldName = projectTable.getName();
|
||||
final String oldSlug = projectTable.getSlug();
|
||||
this.checkProjectAvailability(projectTable.getOwnerId(), compactNewName, skipNameCheck);
|
||||
|
||||
final String oldName = projectTable.getName();
|
||||
final String oldSlug = projectTable.getSlug();
|
||||
final String newSlug = StringUtils.slugify(compactNewName);
|
||||
projectTable.setName(compactNewName);
|
||||
projectTable.setSlug(newSlug);
|
||||
|
@ -213,7 +213,12 @@ public class ProjectService extends HangarComponent {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveSponsors(final String author, final String slug, final String content) {
|
||||
public void saveSponsors(final String author, final String slug, final @Nullable String content) {
|
||||
final String trimmedContent = content != null ? content.trim() : "";
|
||||
if (trimmedContent.length() > this.config.projects.maxSponsorsLen()) {
|
||||
throw new HangarApiException("page.new.error.maxLength");
|
||||
}
|
||||
|
||||
final ProjectTable projectTable = this.getProjectTable(author, slug);
|
||||
projectTable.setSponsors(content);
|
||||
this.projectsDAO.update(projectTable);
|
||||
|
Loading…
Reference in New Issue
Block a user