| Line 13... |
Line 13... |
| 13 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
13 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 14 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
14 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 15 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
15 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 16 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
16 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 17 |
import com.spice.profitmandi.service.AuthService;
|
17 |
import com.spice.profitmandi.service.AuthService;
|
| - |
|
18 |
import com.spice.profitmandi.service.user.UserService;
|
| 18 |
import com.spice.profitmandi.web.model.LoginDetails;
|
19 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 19 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
20 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 20 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
21 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21 |
import org.apache.logging.log4j.LogManager;
|
22 |
import org.apache.logging.log4j.LogManager;
|
| 22 |
import org.apache.logging.log4j.Logger;
|
23 |
import org.apache.logging.log4j.Logger;
|
| 23 |
import org.springframework.beans.factory.annotation.Autowired;
|
24 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 24 |
import org.springframework.beans.factory.annotation.Qualifier;
|
25 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| - |
|
26 |
import org.springframework.beans.factory.annotation.Value;
|
| 25 |
import org.springframework.stereotype.Controller;
|
27 |
import org.springframework.stereotype.Controller;
|
| 26 |
import org.springframework.transaction.annotation.Transactional;
|
28 |
import org.springframework.transaction.annotation.Transactional;
|
| 27 |
import org.springframework.ui.Model;
|
29 |
import org.springframework.ui.Model;
|
| 28 |
import org.springframework.web.bind.annotation.GetMapping;
|
30 |
import org.springframework.web.bind.annotation.GetMapping;
|
| 29 |
import org.springframework.web.bind.annotation.PostMapping;
|
31 |
import org.springframework.web.bind.annotation.PostMapping;
|
| Line 44... |
Line 46... |
| 44 |
|
46 |
|
| 45 |
@Autowired
|
47 |
@Autowired
|
| 46 |
private AuthService authService;
|
48 |
private AuthService authService;
|
| 47 |
|
49 |
|
| 48 |
@Autowired
|
50 |
@Autowired
|
| - |
|
51 |
private UserService userService;
|
| - |
|
52 |
|
| - |
|
53 |
@Value("${prod}")
|
| - |
|
54 |
private boolean isProd;
|
| - |
|
55 |
|
| - |
|
56 |
@Autowired
|
| 49 |
private AuthRepository authRepository;
|
57 |
private AuthRepository authRepository;
|
| 50 |
|
58 |
|
| 51 |
@Autowired
|
59 |
@Autowired
|
| 52 |
private UserRepository userRepository;
|
60 |
private UserRepository userRepository;
|
| 53 |
|
61 |
|
| Line 215... |
Line 223... |
| 215 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
223 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 216 |
authService.changePassword(loginDetails.getEmailId(), oldPassword, newPassword);
|
224 |
authService.changePassword(loginDetails.getEmailId(), oldPassword, newPassword);
|
| 217 |
return "change-auth-user-password";
|
225 |
return "change-auth-user-password";
|
| 218 |
}
|
226 |
}
|
| 219 |
|
227 |
|
| - |
|
228 |
@GetMapping(value = "/resetPasswordPage")
|
| - |
|
229 |
public String getResetPasswordPage(HttpServletRequest request, Model model) {
|
| - |
|
230 |
return "reset-password";
|
| - |
|
231 |
}
|
| - |
|
232 |
|
| - |
|
233 |
@PostMapping(value = "/resetPasswordOverride")
|
| - |
|
234 |
public String resetPasswordOverride(HttpServletRequest request,
|
| - |
|
235 |
@RequestParam(name = "type", defaultValue = "") String type,
|
| - |
|
236 |
@RequestParam(name = "identifier", defaultValue = "") String identifier,
|
| - |
|
237 |
@RequestParam(name = "retailerId", defaultValue = "0") int retailerId,
|
| - |
|
238 |
@RequestParam(name = "newPassword", defaultValue = "") String newPassword, Model model)
|
| - |
|
239 |
throws Exception {
|
| - |
|
240 |
if (isProd) {
|
| - |
|
241 |
throw new ProfitMandiBusinessException("Access Denied", "Environment",
|
| - |
|
242 |
"Password override is disabled in production");
|
| - |
|
243 |
}
|
| - |
|
244 |
if (newPassword.trim().isEmpty()) {
|
| - |
|
245 |
throw new ProfitMandiBusinessException("Password", "newPassword", "New password cannot be blank");
|
| - |
|
246 |
}
|
| - |
|
247 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
248 |
if ("PARTNER".equalsIgnoreCase(type)) {
|
| - |
|
249 |
if (retailerId <= 0) {
|
| - |
|
250 |
throw new ProfitMandiBusinessException("Partner", "retailerId", "Please select a partner");
|
| - |
|
251 |
}
|
| - |
|
252 |
userService.resetPasswordById(retailerId, newPassword);
|
| - |
|
253 |
LOGGER.info("Password override for partner retailerId={} by {}", retailerId, loginDetails.getEmailId());
|
| - |
|
254 |
} else {
|
| - |
|
255 |
if (identifier.trim().isEmpty()) {
|
| - |
|
256 |
throw new ProfitMandiBusinessException("Auth User", "identifier", "Please enter an email or mobile");
|
| - |
|
257 |
}
|
| - |
|
258 |
authService.resetPassword(identifier.trim(), newPassword);
|
| - |
|
259 |
LOGGER.info("Password override for authUser={} by {}", identifier.trim(), loginDetails.getEmailId());
|
| - |
|
260 |
}
|
| - |
|
261 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
262 |
return "response";
|
| - |
|
263 |
}
|
| - |
|
264 |
|
| 220 |
@GetMapping(value = "/getPaginatedAuthUser")
|
265 |
@GetMapping(value = "/getPaginatedAuthUser")
|
| 221 |
public String getPaginatedAuthUser(HttpServletRequest request,
|
266 |
public String getPaginatedAuthUser(HttpServletRequest request,
|
| 222 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
267 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 223 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
268 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
| 224 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
269 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|