Fixed isAdmin at addNewUser endpoint
This commit is contained in:
parent
eeef96ffb6
commit
e062d9254f
@ -31,7 +31,7 @@ public class UserController {
|
|||||||
@RequestParam String forename,
|
@RequestParam String forename,
|
||||||
@RequestParam String login,
|
@RequestParam String login,
|
||||||
@RequestParam String password,
|
@RequestParam String password,
|
||||||
@RequestParam String isAdmin
|
@RequestParam Boolean isAdmin
|
||||||
) {
|
) {
|
||||||
byte[] salt = Hasher.GenerateSalt();
|
byte[] salt = Hasher.GenerateSalt();
|
||||||
byte[] hash;
|
byte[] hash;
|
||||||
@ -50,8 +50,8 @@ public class UserController {
|
|||||||
user.setLogin(login);
|
user.setLogin(login);
|
||||||
user.setPassword(hash);
|
user.setPassword(hash);
|
||||||
user.setSalt(salt);
|
user.setSalt(salt);
|
||||||
user.setToken("test");
|
user.setToken("");
|
||||||
user.setAdmin(isAdmin.equals("1"));
|
user.setAdmin(isAdmin);
|
||||||
|
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
return "" + user.getId();
|
return "" + user.getId();
|
||||||
@ -63,9 +63,10 @@ public class UserController {
|
|||||||
@RequestParam String login,
|
@RequestParam String login,
|
||||||
@RequestParam String password
|
@RequestParam String password
|
||||||
) {
|
) {
|
||||||
System.out.println("LOGIN");
|
System.out.println(login + " tries to login.");
|
||||||
User user = userRepository.findByLogin(login);
|
User user = userRepository.findByLogin(login);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
System.out.println("Login for " + login + " failed.");
|
||||||
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Falscher login");
|
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Falscher login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user