-
30 Mar 2012 4:44 AM #1
login authentication based desktop view extjs 4 with JAVA
login authentication based desktop view extjs 4 with JAVA
hi..
Sencha forum members I am trying to develop an application , in which I want to show the desktop view based on the login authentication.
I had achieved the desktop view in extjs 4, but that doesn't depend on the login authentication. I want to authenticate user based on it designation, and if he is authenticate I will show him his desktop view only.
I am using ext js version 4.0.2a with JAVA as my server side technology.
All kind of suggestion and ideas are welcome.
Yogendra Singh
Sr. Programmer
Kintudesigns.com
-
30 Mar 2012 9:41 AM #2
I use a JSF page for logging then rediect to ExtJS's application page. User's session is created in the backing bean.
First thing app's launch does is checking if user is logged in in the server:
Note that the response from server is used to create the appropiate viewport.Code:launch: function() { Ext.Ajax.request({ url : "./rest/datos/firmado", method : "GET", success : function(r) { if (r.responseText == "0") { // Suscriptor normal Ext.create("AG.view.PrincipalNormal"); } else if (r.responseText == "1") { // Suscriptor Moviclub Ext.create("AG.view.PrincipalMoviclub"); } else { DataUtils.startPage(); } }, failure : function(){ DataUtils.startPage(); } }); }
Each time ExtJS application ask for some service first thing java code does is if there is a valid session, else returns success = false, for example (JAX-RS fragment):
getSuscriptor() is an herited method which throws exception if user is not logged in:Code:@GET @Path("/recibidosmes") @Produces(MediaType.APPLICATION_JSON) public String recibidosMes(@QueryParam("ano") int ano, @QueryParam("mes") int mes) { JsonObject result = new JsonObject(); try { Suscriptor suscriptor = getSuscriptor(); Number cant = (Number) getEntityManager() .createNativeQuery(SQL_RECIBIDOS_MES) .setParameter(1, suscriptor.getId()).setParameter(2, ano) .setParameter(3, mes).getSingleResult(); result.addProperty(ROOT_NAME, cant); result.addProperty(SUCCESS, true); } catch (Throwable t) { logger.error("datosMes()", t); result = processException(t); } return result.toString(); }
Hope this helps.Code:@Inject private SesionUsuario sesionUsuario; protected SesionUsuario getSesionUsuario() { return sesionUsuario; } protected Suscriptor getSuscriptor() throws Exception { if (!sesionUsuario.isFirmado()) { throw new Exception(NO_FIRMADO); } return sesionUsuario.getSuscriptor(); }
Regards.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
30 Mar 2012 8:52 PM #3
@ssamayoa
so much thanks for your response and showing your intereset in this topic.
I had in my mind some ideas please suggest me I am wrong or right.
1. I am using spring so based on the input of user id and password I will redirect the response to my jsp pages.
like if the company person logins, I will redirect him to company.jsp page which will create the whole desktop for him to do all the company task.
2. If the employee person logins, I will redirect him to employee.jsp page which will create the whole desktop for him to do all the employee related tasks like adding attendance, view his working scheduler. etc
3. If the HR logins, I will redirect him to hr.jsp page which will create the whole desktop for him to do all the HR related tasks like making hole schedule for a month, see the working hours of the employee. etc
please suggest me how do I can achieve this using spring. I will send the request to server like userid and password based on it I will redirect them to there respective jsp pages.
Yogendra Singh
Sr. Programmer
Kintudesigns.com


Reply With Quote