Search in sources :

Example 1 with UsersService

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);
}
Also used : User(com.serotonin.m2m2.vo.User) UsersService(com.infiniteautomation.mango.spring.service.UsersService) HashSet(java.util.HashSet)

Example 2 with UsersService

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);
    }
}
Also used : UsersService(com.infiniteautomation.mango.spring.service.UsersService)

Aggregations

UsersService (com.infiniteautomation.mango.spring.service.UsersService)2 User (com.serotonin.m2m2.vo.User)1 HashSet (java.util.HashSet)1