Skip to content

Commit 550f19f

Browse files
vijayanasokanglaumtech
authored andcommitted
Update CustomerController.java
1 parent f73bc2a commit 550f19f

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

login/src/main/java/com/glaum/login/controller/CustomerController.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
import org.springframework.web.bind.annotation.RequestMapping;
1313
import org.springframework.web.bind.annotation.RequestMethod;
1414
import org.springframework.web.bind.annotation.ResponseBody;
15+
import org.springframework.web.context.request.RequestAttributes;
16+
import org.springframework.web.context.request.RequestContextHolder;
17+
import org.springframework.web.context.request.ServletRequestAttributes;
1518

1619
import com.glaum.login.configuration.Authorized;
17-
import com.glaum.login.entity.permission;
20+
1821

1922
import java.io.IOException;
2023
import java.lang.reflect.Field;
@@ -39,35 +42,29 @@ public class CustomerController {
3942
//@PreAuthorize("hasPermission('customer', #httpSession)")
4043
@RequestMapping(value={"/customer"}, method = RequestMethod.GET)
4144
@Authorized(keys = "view_dashboard")
42-
public String customer(HttpSession httpSession,HttpServletRequest request,HttpServletResponse res) throws IOException {
45+
public String customer() throws IOException {
4346

4447
return "admin_customer";
4548
}
4649

4750
@RequestMapping(value={"/quote_delete"}, method = RequestMethod.GET)
4851
@Authorized(keys = {"quote_delete","quote_read","quote_create"})
49-
public String customerdel(HttpSession httpSession,HttpServletRequest request,HttpServletResponse res) throws IOException {
52+
public String customerdel() throws IOException {
5053

5154
return "admin_customer";
5255
}
5356

5457
@RequestMapping(value={"/getuserpermission"}, method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
5558
@Authorized(keys = {"quote_delete","quote_read","quote_create"})
5659
@ResponseBody
57-
public Map<String, Integer> fetchuserpermission(HttpSession httpSession,HttpServletRequest request,HttpServletResponse res) throws IOException {
58-
Map<String,Integer> mapofper= new HashMap<String, Integer>();
59-
60-
for (Field f : httpSession.getClass().getDeclaredFields()) {
61-
f.setAccessible(true);
62-
Object o;
63-
try {
64-
HttpSession s= (HttpSession) f.get(httpSession);
65-
mapofper= (Map<String, Integer>) s.getAttribute("userpermissiondetails");
66-
} catch (Exception e) {
67-
o = e;
68-
}
69-
}
70-
return mapofper;
60+
public Map<String, Integer> fetchuserpermission() throws IOException {
61+
Map<String,Integer> mapofpermission= new HashMap<String, Integer>();
62+
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
63+
HttpServletRequest httprequest = ((ServletRequestAttributes) requestAttributes).getRequest();
64+
HttpSession session = httprequest.getSession();
65+
mapofpermission= (Map<String, Integer>) session.getAttribute("userpermissiondetails");
66+
67+
return mapofpermission;
7168
}
7269

7370

0 commit comments

Comments
 (0)