Fix security on LanguageController

This commit is contained in:
George Kalampokis 2023-10-13 16:46:38 +03:00
parent 959185a6c3
commit 5976084473
1 changed files with 3 additions and 1 deletions

View File

@ -1,8 +1,10 @@
package eu.eudat.controllers;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.Authorities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
@ -48,7 +50,7 @@ public class LanguageController {
@RequestMapping(value = "update/{lang}", method = RequestMethod.POST)
public @ResponseBody
ResponseEntity<ResponseItem<String>> updateLang(@PathVariable String lang, @RequestBody String json) throws Exception {
ResponseEntity<ResponseItem<String>> updateLang(@PathVariable String lang, @RequestBody String json, @ClaimedAuthorities(claims = {Authorities.ADMIN}) Principal principal) throws Exception {
String fileName = this.environment.getProperty("language.path") + lang + ".json";
OutputStream os = new FileOutputStream(fileName);
os.write(json.getBytes());