Merge branch 'develop' into frontend/timo
This commit is contained in:
commit
3110f40826
@ -61,8 +61,6 @@ public class Controller {
|
|||||||
return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll()));
|
return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// user muss jetzt anders aus dem token geholt werden, da kein subject mehr gesetzt wird und username nichtmehr unique ist
|
|
||||||
// (über der checkAdmin methode steht ein möglicher lösungsvorschlag dafür)
|
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping("/api/startCache")
|
@RequestMapping("/api/startCache")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ -85,8 +83,6 @@ public class Controller {
|
|||||||
|
|
||||||
Claims claims = (Claims) tokenVerification.getBody();
|
Claims claims = (Claims) tokenVerification.getBody();
|
||||||
|
|
||||||
|
|
||||||
//Sollte jetzt eigentlich funktionieren...hoffe ich
|
|
||||||
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
|
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
|
||||||
|
|
||||||
if (getUser.getStatusCodeValue() != 200) {
|
if (getUser.getStatusCodeValue() != 200) {
|
||||||
@ -118,16 +114,17 @@ public class Controller {
|
|||||||
Station startStation = cache.getStationen().get(0);
|
Station startStation = cache.getStationen().get(0);
|
||||||
bearbeitet.setAktuelleStation(startStation);
|
bearbeitet.setAktuelleStation(startStation);
|
||||||
|
|
||||||
|
//Get CacheAccesDefinition
|
||||||
|
ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0");
|
||||||
|
|
||||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
if (getCacheAccesDefinition.getStatusCodeValue() != 200) {
|
||||||
cacheAccesDefinitionRepository.findById(0); // angefangen
|
return getCacheAccesDefinition;
|
||||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
|
||||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
|
||||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
|
||||||
} else {
|
|
||||||
return ResponseEntity.status(404).body("There is no cacheAccesDefinition with the ID " + 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody();
|
||||||
|
//----------------------
|
||||||
|
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||||
|
|
||||||
bearbeitetRepository.save(bearbeitet);
|
bearbeitetRepository.save(bearbeitet);
|
||||||
|
|
||||||
return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
|
return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
|
||||||
@ -146,7 +143,6 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//user muss jetzt anders aus dem token geholt werden, da kein subject mehr gesetzt wird und username nichtmehr unique ist
|
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping("/api/checkStation")
|
@RequestMapping("/api/checkStation")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ -261,8 +257,8 @@ public class Controller {
|
|||||||
//----------------------
|
//----------------------
|
||||||
user_info.setRankingPointsSum(user_info.getRankingPointsSum() + cache.getRankingPoints());
|
user_info.setRankingPointsSum(user_info.getRankingPointsSum() + cache.getRankingPoints());
|
||||||
user_infoRepository.save(user_info);
|
user_infoRepository.save(user_info);
|
||||||
bearbeitetRepository.save(bearbeitet);
|
|
||||||
}
|
}
|
||||||
|
bearbeitetRepository.save(bearbeitet);
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitet));
|
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitet));
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
|
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
|
||||||
@ -292,15 +288,20 @@ public class Controller {
|
|||||||
|
|
||||||
ResponseEntity userResponse = FinderUtil.findUserFromClaim(claims);
|
ResponseEntity userResponse = FinderUtil.findUserFromClaim(claims);
|
||||||
|
|
||||||
if(userResponse.getStatusCodeValue() != 200){
|
if (userResponse.getStatusCodeValue() != 200) {
|
||||||
return userResponse;
|
return userResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = (User) userResponse.getBody();
|
User user = (User) userResponse.getBody();
|
||||||
|
|
||||||
//TODO Hier Admin Check einfügen
|
List<Role> roles = user.getRoles();
|
||||||
|
for (Role role : roles) {
|
||||||
|
if (role.getDomain().equals("geocaching.de") && role.getName().equals("ADMIN")) {
|
||||||
|
return ResponseEntity.status(200).body(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ResponseEntity.status(200).body(claims.get("admin"));
|
return ResponseEntity.status(404).body(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@ -354,8 +355,6 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ich hab mal eine Hilfsklasse erstellt, damit die Daten in einer schöneren Form ins Frontend kommen und da quasi nichts geändert
|
|
||||||
// werden muss. Ich konnte es noch nicht ausprobieren, da die se server down sind (11:05 Uhr)
|
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping("/api/getRankingList")
|
@RequestMapping("/api/getRankingList")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user