예제 #1
0
 public Integer savePasswordChanged(ChangePassword cp) {
   Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
   cp.setPassword(passwordEncoder.encodePassword(cp.getPassword(), null));
   cp.setNewpassword(passwordEncoder.encodePassword(cp.getNewpassword(), null));
   Query query =
       new Query(Criteria.where("id").is(cp.getUserid()).and("password").is(cp.getPassword()));
   Users usr = mongoTemplate.findOne(query, Users.class);
   if (null != usr) {
     usr.setPassword(cp.getNewpassword());
     usr.setModifiedDate(new Date());
     userRepository.save(usr);
     return 1;
   } else {
     return 0;
   }
 }
예제 #2
0
  public int resetAndSavePassword(String email) {
    Users user = userRepository.findByEmail(email);
    if (null == user) {
      return 0;
    } else {

      Random randomGenerator = new Random();
      int randomInt = randomGenerator.nextInt(100000);

      Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
      user.setPassword(passwordEncoder.encodePassword(randomInt + "", null));

      userRepository.save(user);
      return randomInt;
    }
  }
예제 #3
0
  public String save(Users users) {
    // System.out.println("users.getjoinedid:::: "+users.getJoinedid());
    if (StringUtils.isNotEmpty(users.getId())) {
      Users userstmp = getUserForEdit(users.getId());
      userstmp.setColorTheme(users.getColorTheme());
      userstmp.setName(users.getName());
      userstmp.setEmail(users.getEmail());
      userstmp.setModifiedDate(new Date());
      users = userstmp;
    } else {
      if (userRepository.findByUsername(users.getUsername()) != null) {
        return "username";
      } else if (userRepository.findByEmail(users.getEmail()) != null) {
        return "email";
      }
      Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
      users.setPassword(passwordEncoder.encodePassword(users.getPassword(), null));
      users.setCreatedDate(new Date());
      users.setModifiedDate(new Date());
    }

    userRepository.save(users);
    return "save";
  }