示例#1
0
 @Override
 protected void onPostExecute(User u) {
   // TODO Auto-generated method stub
   if (u != null) {
     if (u.getProfile_id() == PROFILE_ADMIN_ID) {
       user = u;
       Intent go_to_cartacliente = new Intent("com.roamtouch.menuserver.ADMIN");
       Bundle args = new Bundle();
       args.putString("ip_maestra", ip_maestra);
       go_to_cartacliente.putExtras(args);
       startActivity(go_to_cartacliente);
     } else {
       Toast.makeText(
               LoginActivity.this,
               "Acceso denegado para el usuario ingresado!",
               Toast.LENGTH_SHORT)
           .show();
     }
   } else {
     Toast.makeText(LoginActivity.this, "Usuario o contrasenia incorrecto", Toast.LENGTH_SHORT)
         .show();
   }
 }
示例#2
0
    public User checkUser(String username, String password) {
      JSONArray jsonUser = null;
      User u = null;

      Param paramPost = new Param();
      paramPost.addParam("action", Integer.toString(CHECK_USER));
      paramPost.addParam("username", username);
      paramPost.addParam("password", password);

      try {
        jsonUser = request.postData(ip_maestra, paramPost);

        // looping
        if (jsonUser != null) {
          for (int i = 0; i < jsonUser.length(); i++) {
            JSONObject m = jsonUser.getJSONObject(i);
            u = new User();
            u.set_id(m.getInt("_id"));
            u.setUsername(m.getString("username"));
            u.setPassword(m.getString("password"));
            u.setFirst_name(m.getString("first_name"));
            u.setFirst_name(m.getString("last_name"));
            u.setEmail(m.getString("email"));
            u.setStatus(m.getInt("status"));
            u.setProfile_id(m.getInt("profile_id"));
            u.setProfile_description(m.getString("description"));
            u.setCreated_at(m.getString("created_at"));
            u.setUpdated_at(m.getString("updated_at"));
            Log.d("outPut", "user username: "******"username"));
          }
        }
      } catch (JSONException e) {
        e.printStackTrace();
      }

      return u;
    }