Skip to content
Snippets Groups Projects
Commit cd0625a4 authored by Seb Barnard's avatar Seb Barnard :speech_balloon:
Browse files

Added proper authentication to route

parent 7921b058
No related branches found
No related tags found
3 merge requests!114LoggingService service class, new method to add a log to the "Logs" table when...,!76Branch Update,!75Issue eighteen
......@@ -20,4 +20,14 @@ public class UserLinked {
}
} return false;
}
public boolean isAdmin(int userId, int shopId){
List<UserPermissions> allLinks = userPermRepo.findByUserId(userId);
for(UserPermissions u:allLinks){
if(u.getShop().getShopId() == shopId){
if (u.getAdminType().getAdminTypeId() == 2) {
return true;
}
}
} return false;
}
}
......@@ -40,7 +40,8 @@ public class UpdateStaff {
@PostMapping("/updateStaff")
public String addStaff(UpdateStaffForm usf, HttpSession session){
if(!userLinked.isLinked(jwtUtils.getLoggedInUserId(session).get(), usf.getShopId())){
if((!userLinked.isLinked(jwtUtils.getLoggedInUserId(session).get(), usf.getShopId())) &&
(!userLinked.isAdmin(jwtUtils.getLoggedInUserId(session).get(), usf.getShopId()))){
return "USER NOT AUTHENTICATED";
}
int userId;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment