| Line 7... |
Line 7... |
| 7 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
7 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 8 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
8 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
| 9 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
9 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 10 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
10 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 11 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
11 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
| - |
|
12 |
import com.spice.profitmandi.service.mail.MailOutboxService;
|
| 12 |
import com.spice.profitmandi.service.user.UserService;
|
13 |
import com.spice.profitmandi.service.user.UserService;
|
| 13 |
import org.apache.commons.lang.RandomStringUtils;
|
14 |
import org.apache.commons.lang.RandomStringUtils;
|
| 14 |
import org.apache.logging.log4j.LogManager;
|
15 |
import org.apache.logging.log4j.LogManager;
|
| 15 |
import org.apache.logging.log4j.Logger;
|
16 |
import org.apache.logging.log4j.Logger;
|
| 16 |
import org.springframework.beans.factory.annotation.Autowired;
|
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| Line 40... |
Line 41... |
| 40 |
|
41 |
|
| 41 |
@Autowired
|
42 |
@Autowired
|
| 42 |
JavaMailSender mailSender;
|
43 |
JavaMailSender mailSender;
|
| 43 |
|
44 |
|
| 44 |
@Autowired
|
45 |
@Autowired
|
| - |
|
46 |
MailOutboxService mailOutboxService;
|
| - |
|
47 |
|
| - |
|
48 |
@Autowired
|
| 45 |
PromoterRepository promoterRepository;
|
49 |
PromoterRepository promoterRepository;
|
| 46 |
|
50 |
|
| 47 |
@Autowired
|
51 |
@Autowired
|
| 48 |
UserRepository userRepository;
|
52 |
UserRepository userRepository;
|
| 49 |
|
53 |
|
| Line 123... |
Line 127... |
| 123 |
@Override
|
127 |
@Override
|
| 124 |
public void resetPassword(String emailOrMobile) throws ProfitMandiBusinessException {
|
128 |
public void resetPassword(String emailOrMobile) throws ProfitMandiBusinessException {
|
| 125 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailOrMobile);
|
129 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailOrMobile);
|
| 126 |
String password = getRandomString();
|
130 |
String password = getRandomString();
|
| 127 |
try {
|
131 |
try {
|
| 128 |
Utils.sendMailWithAttachments(mailSender, authUser.getEmailId(), null, RESET_PASSWORD_SUBJECT,
|
132 |
mailOutboxService.queueMail(authUser.getEmailId(), null, RESET_PASSWORD_SUBJECT,
|
| 129 |
String.format(RESET_PASSWORD_BODY, authUser.getFirstName(), password), null);
|
133 |
String.format(RESET_PASSWORD_BODY, authUser.getFirstName(), password), "AuthServiceImpl.resetPassword");
|
| 130 |
} catch (Exception e) {
|
134 |
} catch (Exception e) {
|
| 131 |
throw new ProfitMandiBusinessException("Password Reset Email", emailOrMobile,
|
135 |
throw new ProfitMandiBusinessException("Password Reset Email", emailOrMobile,
|
| 132 |
"Could not send password reset mail. Password Could not be reset");
|
136 |
"Could not send password reset mail. Password Could not be reset");
|
| 133 |
}
|
137 |
}
|
| 134 |
userService.resetPassword(emailOrMobile, password);
|
138 |
userService.resetPassword(emailOrMobile, password);
|