Subversion Repositories SmartDukaan

Rev

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

Rev 23984 Rev 24099
Line 15... Line 15...
15
import org.springframework.stereotype.Component;
15
import org.springframework.stereotype.Component;
16
import org.springframework.transaction.annotation.Transactional;
16
import org.springframework.transaction.annotation.Transactional;
17
 
17
 
18
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
18
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
19
import com.spice.profitmandi.common.model.ProfitMandiConstants;
19
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
20
import com.spice.profitmandi.common.util.DesEncrypter;
20
import com.spice.profitmandi.dao.entity.dtr.ActivationCode;
21
import com.spice.profitmandi.dao.entity.dtr.ActivationCode;
21
import com.spice.profitmandi.dao.entity.dtr.Retailer;
22
import com.spice.profitmandi.dao.entity.dtr.Retailer;
22
import com.spice.profitmandi.dao.entity.dtr.Role;
23
import com.spice.profitmandi.dao.entity.dtr.Role;
23
import com.spice.profitmandi.dao.entity.dtr.User;
24
import com.spice.profitmandi.dao.entity.dtr.User;
24
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
25
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
Line 45... Line 46...
45
	@Autowired
46
	@Autowired
46
	@Qualifier(value = "userRepository")
47
	@Qualifier(value = "userRepository")
47
	private UserRepository userRepository;
48
	private UserRepository userRepository;
48
 
49
 
49
	@Autowired
50
	@Autowired
-
 
51
	@Qualifier(value = "userUserRepository")
-
 
52
	private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
-
 
53
 
-
 
54
	@Autowired
50
	private RetailerRepository retailerRepo;
55
	private RetailerRepository retailerRepo;
51
	
56
	
52
	@Autowired
57
	@Autowired
53
	private FofoStoreRepository fofoStoreRepository;
58
	private FofoStoreRepository fofoStoreRepository;
54
	
59
	
Line 59... Line 64...
59
	private UserRoleRepository userRoleRepository;
64
	private UserRoleRepository userRoleRepository;
60
	
65
	
61
	@Autowired
66
	@Autowired
62
	private RoleRepository roleRepository;
67
	private RoleRepository roleRepository;
63
	
68
	
-
 
69
	private static final DesEncrypter encrypter = new DesEncrypter("saholic");
-
 
70
	
64
 
71
	
65
	@SuppressWarnings("deprecation")
72
	@SuppressWarnings("deprecation")
66
	@Override
73
	@Override
67
	public boolean updateActivation(int userId, int retailerId, String activationCode) throws Throwable {
74
	public boolean updateActivation(int userId, int retailerId, String activationCode) throws Throwable {
68
		
75
		
69
		TransactionClient transactionServiceClient = new TransactionClient();
76
		TransactionClient transactionServiceClient = new TransactionClient();
Line 130... Line 137...
130
		 {
137
		 {
131
			 userIdEmailIdMap.put(user.getId(),user.getEmailId());
138
			 userIdEmailIdMap.put(user.getId(),user.getEmailId());
132
		 }
139
		 }
133
		return userIdEmailIdMap;
140
		return userIdEmailIdMap;
134
	}
141
	}
-
 
142
 
-
 
143
 
-
 
144
	@Override
-
 
145
	public User authenticate(String emailMobile, String password) throws ProfitMandiBusinessException {
-
 
146
		User user = userRepository.selectByEmailIdOrMobileNumber(emailMobile);
-
 
147
		com.spice.profitmandi.dao.entity.user.User userUser = userUserRepository.selectByEmailId(user.getEmailId());
-
 
148
		if(!user.getPassword().equals(encrypter.decrypt(password))) {
-
 
149
			throw new ProfitMandiBusinessException("Username Password", emailMobile, "Invalid Username or Password");
-
 
150
		}
-
 
151
		return user;
-
 
152
	}
-
 
153
 
-
 
154
 
-
 
155
	@Override
-
 
156
	public boolean resetPassword(String emailMobile, String password) throws ProfitMandiBusinessException {
-
 
157
		User user = userRepository.selectByEmailIdOrMobileNumber(emailMobile);
-
 
158
		user.setPassword(encrypter.encrypt(password));
-
 
159
		userRepository.persist(user);
-
 
160
		return true;
-
 
161
	}
135
	
162
	
136
}
163
}