Search in sources :

Example 26 with User

use of org.survey.model.user.User in project survey by markoniemi.

the class UserServiceTestBase method delete.

@Test
public void delete() {
    create();
    for (int i = 0; i < ENTITY_COUNT; i++) {
        User entity = orginalEntities.get(i);
        entityService.delete(entity.getUsername());
        Assert.assertFalse(entityService.exists(entity.getUsername()));
    }
    Assert.assertEquals(0, entityService.count());
}
Also used : User(org.survey.model.user.User) Test(org.junit.Test)

Example 27 with User

use of org.survey.model.user.User in project survey by markoniemi.

the class EditUserBean method addUser.

public String addUser() {
    user = new User();
    user.setRole(Role.ROLE_USER);
    return "addUser";
}
Also used : User(org.survey.model.user.User)

Example 28 with User

use of org.survey.model.user.User in project survey by markoniemi.

the class UserRepositoryAuthenticationProvider method authenticate.

/**
 * Authenticate using UserRepository.
 */
@Override
public Authentication authenticate(Authentication authentication) {
    log.debug("authenticate:" + authentication.getName());
    User user = userService.findOne(authentication.getName());
    return UserRepositoryAuthenticationProvider.authenticateUser(user, authentication);
}
Also used : User(org.survey.model.user.User)

Example 29 with User

use of org.survey.model.user.User in project survey by markoniemi.

the class PollServiceImpl method findByOwner.

public Poll[] findByOwner(String username) {
    User user = userRepository.findByUsername(username);
    if (user == null) {
        return EMPTY_POLL_ARRAY;
    }
    Iterable<Poll> polls = pollRepository.findAllByOwner(user);
    // return empty list instead of null
    if (Iterables.isEmpty(polls)) {
        return EMPTY_POLL_ARRAY;
    } else {
        return Iterables.toArray(polls, Poll.class);
    }
}
Also used : User(org.survey.model.user.User) Poll(org.survey.model.poll.Poll)

Example 30 with User

use of org.survey.model.user.User in project survey by markoniemi.

the class UserServiceImpl method delete.

@Override
public void delete(String username) {
    log.trace("delete: {}", username);
    User user = userRepository.findByUsername(username);
    // Validate.notNull(user, "User does not exist.");
    if (user == null) {
        return;
    }
    List<File> files = fileRepository.findAllByOwner(user);
    fileRepository.delete(files);
    userRepository.delete(user.getId());
}
Also used : User(org.survey.model.user.User) File(org.survey.model.file.File)

Aggregations

User (org.survey.model.user.User)30 Test (org.junit.Test)20 HashMap (java.util.HashMap)4 JWTExpiredException (com.auth0.jwt.JWTExpiredException)3 JWTVerifyException (com.auth0.jwt.JWTVerifyException)3 Before (org.junit.Before)3 BindException (org.springframework.validation.BindException)2 Errors (org.springframework.validation.Errors)2 UserValidator (org.survey.controller.UserValidator)2 JWTSigner (com.auth0.jwt.JWTSigner)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 File (org.survey.model.file.File)1 Poll (org.survey.model.poll.Poll)1 CrudRepositoryTest (org.survey.repository.CrudRepositoryTest)1