简体   繁体   中英

Sencha Touch Login validation with MSSQL database

I want to build a client/server application using Sencha Touch 2 on the client side and Java/hibernate/MSSQL database technology on the server side. To get started I created the client side user login frame.Now i need help to implement the server side of the application. That is, to take the username/password and send it to the server and validate if the login is correct or not. Can somebody please help me to achieve this part. I am using Tomcat as the container for my server side.

It is very Easy,Below code not totally working ,but it will give you just an idea,to start.

  1. Create Login form in sencha touch(Login.js)
  2. Write a Login Controller in sencha touch which is responsible for making Ajax request from front end to backend. This controller should contain below line of code inside a function.

    var user = Ext.getCmp('user_name');

    var pass = Ext.getCmp('password');

    // For security purpose you should always pass credntial in encrypted format

    var param = {user_name:user,password:pass};

    var jsonData = JSON.stringify(param);

Ext.Ajax.request({

       url: 'http://server_ip:8080/backend/authenticate',


       jsonData : param,


    success: function(response){
      Ext.Msg.Alert(null,"Login Successfule");
      //You can write your own logic to display any other screen
    }



    failure : function(error){
      Ext.Msg.Alert(null,"Unable to authenticate user");
    }

});

3.Now prepare you back end using any frame work in java let say Spring MVC. 4. Write a controller

 @Controller
  public class AuthenticateController{
     @RequestMapping(value="authenticate",method = RequestMethod.POST,consumes="application/json",produces="application/json")
     @ResponseBody
     public String authenticateUser((@RequestBody String json){
        //Now by using json data you can verify user by querying DB,and return your own message.
     }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM