1. #1
    Sencha User
    Join Date
    Apr 2011
    Location
    Surat, Gujarat, India
    Posts
    126
    Vote Rating
    0
    rushi2440 is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,329
    Vote Rating
    212
    ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold

      0  

    Default


    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:

    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();
                }
            });
        }
    Note that the response from server is used to create the appropiate viewport.

    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):
    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();
        }
    getSuscriptor() is an herited method which throws exception if user is not logged in:

    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();
        }
    Hope this helps.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Location
    Surat, Gujarat, India
    Posts
    126
    Vote Rating
    0
    rushi2440 is on a distinguished road

      0  

    Default


    @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

Thread Participants: 1

Tags for this Thread