@Override public boolean isOldPasswordCorrect(String password, int userId) { User user = findUserById(userId); if (user.getPassword().equals(password)) { return true; } return false; }
@Override public boolean changePassword(String password, int userId) { User user = findUserById(userId); user.setPassword(password); try { em.persist(user); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
@Override public User create(User user) { if (user.getId() <= 0) { em.persist(user); } else { user = em.merge(user); } return user; }