Subversion Repositories SmartDukaan

Rev

Rev 26842 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26842 Rev 34190
Line 65... Line 65...
65
		String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
65
		String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
66
		return generatedString;
66
		return generatedString;
67
	}
67
	}
68
 
68
 
69
	@Override
69
	@Override
70
	public void resetPassword(String mobile) throws ProfitMandiBusinessException {
70
	public boolean changePassword(String mobileNumber, String oldPassword, String newPassword) throws ProfitMandiBusinessException {
-
 
71
		if(newPassword==null || newPassword.isEmpty()) {
-
 
72
			throw new ProfitMandiBusinessException("error","","Password cannot be empty");
-
 
73
		}
-
 
74
		if(oldPassword==null || oldPassword.isEmpty()) {
-
 
75
			throw new ProfitMandiBusinessException("error", "", "Old Password cannot be empty");
-
 
76
		}
-
 
77
		if(mobileNumber==null || mobileNumber.isEmpty()) {
-
 
78
			throw new ProfitMandiBusinessException("error", "", "Mobile number cannot be empty");
-
 
79
		}
-
 
80
		if(!customerRepository.authenticate(mobileNumber, getHash256(oldPassword))) {
-
 
81
			throw new ProfitMandiBusinessException("error", "", "Old Password is not correct");
-
 
82
		}
-
 
83
		if(customerRepository.authenticate(mobileNumber, getHash256(newPassword))) {
-
 
84
			throw new ProfitMandiBusinessException("error", "", "New Password cannot be same as old password");
-
 
85
		}
-
 
86
 
-
 
87
		Customer customer = customerRepository.selectByMobileNumber(mobileNumber);
-
 
88
		if(customer==null) {
-
 
89
			throw new ProfitMandiBusinessException("error", "", "Mobile number does not exist");
-
 
90
		}
71
		// TODO Auto-generated method stub
91
		 if(customer.getPassword()==null) {
-
 
92
			throw new ProfitMandiBusinessException("error", "", "Password cannot be empty");
72
		
93
		}
-
 
94
		LOGGER.info(customer+" customer data is fetched successfully");
-
 
95
		if(customer.getPassword().equals(getHash256(oldPassword))) {
-
 
96
			customer.setPassword(getHash256(newPassword));
-
 
97
			LOGGER.info("Password changed successfully");
-
 
98
			return true;
73
	}
99
		}
-
 
100
		return false;
-
 
101
    }
74
 
102
 
75
	@Override
103
	@Override
76
	public void changePassword(String mobileNumber, String newPassword)
104
	public void resetPassword(String mobileNumber, String newPassword)
77
			throws ProfitMandiBusinessException {
105
			throws ProfitMandiBusinessException {
78
		Customer customer = customerRepository.selectByMobileNumber(mobileNumber);
106
		Customer customer = customerRepository.selectByMobileNumber(mobileNumber);
79
		customer.setPassword(getHash256(newPassword));
107
		customer.setPassword(getHash256(newPassword));
80
	}
108
	}
81
 
109