Merge pull request #643 from TortugaAttack/multipleTracker45
Fixed #642 - multiple tracker for one user fixed
This commit is contained in:
commit
c93563da3f
@ -30,14 +30,26 @@ public class UserService implements UserDetailsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addUser(String username, String password) {
|
public void addUser(String username, String password) {
|
||||||
|
//get user if there exists one by the name
|
||||||
|
WebGoatUser webGoatUser = userRepository.findByUsername(username);
|
||||||
|
//if user exists it will be updated, otherwise created
|
||||||
userRepository.save(new WebGoatUser(username, password));
|
userRepository.save(new WebGoatUser(username, password));
|
||||||
|
//if user previously existed it will not get another tracker
|
||||||
|
if (webGoatUser == null) {
|
||||||
userTrackerRepository.save(new UserTracker(username));
|
userTrackerRepository.save(new UserTracker(username));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addUser(String username, String password, String role) {
|
public void addUser(String username, String password, String role) {
|
||||||
|
//get user if there exists one by the name
|
||||||
|
WebGoatUser webGoatUser = userRepository.findByUsername(username);
|
||||||
|
//if user exists it will be updated, otherwise created
|
||||||
userRepository.save(new WebGoatUser(username,password,role));
|
userRepository.save(new WebGoatUser(username,password,role));
|
||||||
|
//if user previously existed it will not get another tracker
|
||||||
|
if (webGoatUser == null) {
|
||||||
userTrackerRepository.save(new UserTracker(username));
|
userTrackerRepository.save(new UserTracker(username));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<WebGoatUser> getAllUsers () {
|
public List<WebGoatUser> getAllUsers () {
|
||||||
return userRepository.findAll();
|
return userRepository.findAll();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user