Compare commits

..

2 Commits

Author SHA1 Message Date
5cdab5b434 Merge branch 'master' into merge 2022-02-07 11:28:06 +01:00
24794e2085 Create user on first login 2022-02-05 23:31:22 +01:00

View File

@ -83,6 +83,27 @@ public class UserController {
@RequestParam String login,
@RequestParam String password
) {
if(userRepository.findAllUsernames().length == 0){
byte[] salt = Hasher.GenerateSalt();
byte[] hash;
try {
hash = Hasher.HashPassword(password, salt);
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
e.printStackTrace();
return new ResponseEntity<>("Fehler beim hashen", HttpStatus.INTERNAL_SERVER_ERROR);
}
User user = new User();
user.setName("Admin");
user.setForename(login);
user.setLogin(login);
user.setPassword(hash);
user.setSalt(salt);
user.setToken("");
user.setAdmin(true);
userRepository.save(user);
}
System.out.println(login + " tries to login.");
User user = userRepository.findByLogin(login);
if (user == null) {