In Semester Edit and Create there are real users to select now
And dummy data of modules to select from a list
This commit is contained in:
@@ -442,6 +442,33 @@ public class DataBaseHandler
|
||||
/**
|
||||
USER
|
||||
*/
|
||||
|
||||
|
||||
//TODO: Nur nicht admins werden aktuell ausgegeben
|
||||
public User[] getAllUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
ResultSet rs = st.executeQuery("select * from users where permission=0");
|
||||
|
||||
User u = null;
|
||||
|
||||
List<User> output = new ArrayList<>();
|
||||
|
||||
while((u = resultSetToUser(rs)) != null)
|
||||
{
|
||||
u.clearOutPassword();
|
||||
output.add(u);
|
||||
}
|
||||
|
||||
return output.toArray(new User[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//get a user object by mail and password from the database
|
||||
public User getUser(String mail, String password)
|
||||
{
|
||||
|
||||
@@ -151,4 +151,19 @@ public class UserController {
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/users/all")
|
||||
public ResponseEntity<User[]> getAllUsers(@RequestParam(name = "sessionid") String sessionid)
|
||||
{
|
||||
User u = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||
|
||||
if(u != null && u.getPermissions() == UserPermissions.admin.getValue())
|
||||
{
|
||||
User[] output = db.getAllUsers();
|
||||
return new ResponseEntity<>(output, HttpStatus.OK);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user