interim missing function ac commit, traversing dev. env.
This commit is contained in:
@ -2,6 +2,8 @@ package org.owasp.webgoat.users;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nbaars
|
||||
* @since 3/19/17.
|
||||
@ -9,4 +11,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
public interface UserRepository extends MongoRepository<WebGoatUser, String> {
|
||||
|
||||
WebGoatUser findByUsername(String username);
|
||||
|
||||
List<WebGoatUser> findAll();
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nbaars
|
||||
* @since 3/19/17.
|
||||
@ -31,4 +33,14 @@ public class UserService implements UserDetailsService {
|
||||
userRepository.save(new WebGoatUser(username, password));
|
||||
userTrackerRepository.save(new UserTracker(username));
|
||||
}
|
||||
|
||||
public void addUser(String username, String password, String role) {
|
||||
userRepository.save(new WebGoatUser(username,password,role));
|
||||
userTrackerRepository.save(new UserTracker(username));
|
||||
}
|
||||
|
||||
public List<WebGoatUser> getAllUsers () {
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,12 @@ public class WebGoatUser implements UserDetails {
|
||||
createUser();
|
||||
}
|
||||
|
||||
public WebGoatUser(String username, String password, String role) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public void createUser() {
|
||||
this.user = new User(username, password, getAuthorities());
|
||||
}
|
||||
|
Reference in New Issue
Block a user