验证为何绕过

时间:2017-01-15 14:46:25

标签: android codeigniter okhttp3

我使应用程序android与codeigniter连接,但为什么我输入错误的用户名和密码,身份验证不起作用。就像绕过MainActivity.class一样,请告诉我什么错了?

这是我的代码:

public void onClick(View view){
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
        RequestBody formBody = new FormBody.Builder().add("username_kirim", username.getText().toString())
                .add("password_kirim", password.getText().toString())
                .build();
        Request request = new Request.Builder().url(url_login).post(formBody).build();
        try {
            Response response = client.newCall(request).execute();
            if(!response.isSuccessful()){
                throw new IOException("Gagal Terkoneksi" + response);
            }
            if(response.isSuccessful()){
                if(checkFlag){
                    editor.putString("username", username.getText().toString());
                    editor.putString("password", password.getText().toString());
                    editor.apply();
                }
                Intent loged = new Intent(LoginActivity.this, MainActivity.class);
                startActivity(loged);
            }

        }
        catch (IOException e){
            e.printStackTrace();
        }
    }

1 个答案:

答案 0 :(得分:1)

仅仅因为查询成功并不意味着它包含数据,0行仍然可以成功执行查询。