Commit f6abcd6f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

okStatus refactored

parent cc12f34d
......@@ -95,4 +95,12 @@ public abstract class BaseController {
.header("Content-Disposition", "attachment; filename=" + originalFile.getOriginalFileName() + ".zip")
.body(baos.toByteArray());
}
protected Map<String, Object> okStatus() {
Map<String, Object> result = new HashMap<>();
result.put("status", "OK");
return result;
}
}
......@@ -256,9 +256,7 @@ public class PluginController extends BaseController {
} else {
pluginService.delete(entry);
}
Map<String, Object> result = new HashMap<>();
result.put("status", "ok");
return result;
return okStatus();
}
private PluginDataEntry createPluginDataEntry(String hash, User user, String key, String value)
......
......@@ -412,11 +412,11 @@ public class UserController extends BaseController {
throw new OperationNotAllowedException("guest account cannot be removed");
}
userService.deleteUser(user);
return new HashMap<>();
return okStatus();
}
@PostMapping(value = "/users/{login}:requestResetPassword")
public Map<String, Object> requestResetPasswordToken(
public Object requestResetPasswordToken(
@PathVariable(value = "login") String login) throws QueryException, MessagingException {
User user = userService.getUserByLogin(login);
if (user == null) {
......@@ -438,21 +438,17 @@ public class UserController extends BaseController {
}
userService.createResetPasswordToken(user);
Map<String, Object> result = new HashMap<>();
result.put("status", "OK");
return result;
return okStatus();
}
@PostMapping(value = "/users:resetPassword")
public Map<String, Object> resetPassword(
public Object resetPassword(
@RequestParam(value = "token") String token,
@RequestParam(value = "password") String password)
throws IOException, QueryException {
try {
userService.resetPassword(token, passwordEncoder.encode(password));
Map<String, Object> result = new HashMap<>();
result.put("status", "OK");
return result;
return okStatus();
} catch (InvalidTokenException e) {
throw new ObjectNotFoundException("Invalid token", e);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment