use of com.infiniteautomation.mango.spring.service.UsersService in project ma-core-public by infiniteautomation.
the class MangoTestBase method createUser.
/**
* Create a user with pre-assigned ID
*/
protected User createUser(int id, String name, String username, String password, String email, Role... roles) {
User user = new User();
user.setId(id);
user.setName(name);
user.setUsername(username);
user.setPassword(Common.encrypt(password));
user.setEmail(email);
user.setPhone("");
user.setRoles(Collections.unmodifiableSet(new HashSet<>(Arrays.asList(roles))));
user.setDisabled(false);
UsersService service = Common.getBean(UsersService.class);
return service.insert(user);
}
use of com.infiniteautomation.mango.spring.service.UsersService in project ma-core-public by infiniteautomation.
the class User method jsonWrite.
@Override
public void jsonWrite(ObjectWriter writer) throws IOException, JsonException {
writer.writeEntry("name", name);
UsersService usersService = Common.getBean(UsersService.class);
// users with create permission do not have read permission for the user they created
if (usersService.hasReadPermission(Common.getUser(), this)) {
List<LinkedAccount> linkedAccounts = usersService.getLinkedAccounts(this);
writer.writeEntry("linkedAccounts", linkedAccounts);
}
}
Aggregations