예제 #1
0
 public byte[] getCurrentAvatar(User user) throws IOException {
   byte[] avatar = user.getAvatar();
   if (avatar == null) {
     InputStream in =
         this.getClass().getClassLoader().getResourceAsStream("image/default-avatar.png");
     return IOUtils.toByteArray(in);
   }
   return avatar;
 }
예제 #2
0
 public void addUser(RegisterForm form) {
   User user = new User();
   user.setUsername(form.getUsername());
   user.setEmail(form.getEmail());
   user.setPassword(form.getPassword());
   user.setEnabled(true);
   user.setAuthority("ROLE_USER");
   userDao.save(user);
 }
예제 #3
0
 public void setAvatar(User user, MultipartFile avatar) throws IOException {
   user.setAvatar(IOUtils.toByteArray(avatar.getInputStream()));
   userDao.save(user);
 }
예제 #4
0
 public void blockUser(String username) {
   User user = userDao.getUserByName(username);
   user.setEnabled(!user.isEnabled());
   userDao.save(user);
 }