Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid Duplicate Number OTP android #96

Open
zakblacki opened this issue Sep 11, 2020 · 0 comments
Open

Forbid Duplicate Number OTP android #96

zakblacki opened this issue Sep 11, 2020 · 0 comments

Comments

@zakblacki
Copy link

zakblacki commented Sep 11, 2020

In my signup page I want to forbid Users from using the same number.

This part is already done. The problem if a client use the same number starting with or without "0" at the beginning after country code it won't be considered as taken.

Example :

+213 056XXXX

+213 56XXXX

This will work on both cases and won't be considered as registered. How do I fix this ?

GetUserNumber

   ` confirm.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Snumber = number.getText().toString().trim();
        if (Snumber.equals("") || !Patterns.PHONE.matcher(Snumber).matches() ) {
            number.setError(getApplicationContext().getResources().getString(R.string.enter_number));
            number.requestFocus();
        } else {
            Snumber = countryCodePicker.getSelectedCountryCode().toString() + number.getText().toString().trim();
            if (new Check_internet_connection(getApplicationContext()).isNetworkAvailable()) {                        getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
                        WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                relativeLayout.setVisibility(View.VISIBLE);
                rotateLoading.start();
                new VerifyNumberDuplication().execute();
            } else {
            }

  public class VerifyNumberDuplication extends AsyncTask<String, Void, String> {
  @Override
  protected void onPreExecute() {
  }
 @Override
 protected String doInBackground(String... params) {
    try {
        JSONObject obj = new JSONObject();
        obj.put("operation", "verify");
        obj.put("number", Snumber);
        String str_req = JsonParser.multipartFormRequestForFindFriends(ServerURL.Url, "UTF-8", obj, null);
        jp_obj = new JSONObject(str_req);
        jar_array = jp_obj.getJSONArray("JsonData");
        JSONObject c;
        c = jar_array.getJSONObject(0);
        server_response = c.getString("response");
        if (server_response.equals("1")) {
            server_response_text = c.getString("response-text");
        }
        else {
            server_response_text = c.getString("response-text");
        }
        server_check = true;
    } catch (Exception e) {
        e.printStackTrace();
        //server response/////////////////////////
        server_check = false;
    }
    return null;
  }
  @Override
  protected void onPostExecute(String s) {
    rotateLoading.stop();
    relativeLayout.setVisibility(View.GONE);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
    if (server_check) {
        if (server_response.equals("1")) {
        } else {
            Intent intent = new Intent(GetUserNumber.this, VerifyNumberActivity.class);
            intent.putExtra("number", Snumber);
            intent.putExtra("type", type);
            startActivity(intent);
        }
    } 
 }}`

load_data.php

 `//number verification
 if($operation && $operation == 'verify' && $number)
{ 

$select = 'select * from users where number="'.$number.'" ';
$query  = $conect->select_custom($select);

 if($query->num_rows > 0)
{
 $JsonArray   = array();

  $JsonArray[] = array('response'=>'1', 'response-text'=>'Number already used');
  echo json_encode(array('JsonData'=>$JsonArray),JSON_PRETTY_PRINT);
 }
else
 {
 $JsonArray   = array();
 $JsonArray[] = array('response'=>'0', 'response-text'=>"This number does not exist");
  echo json_encode(array('JsonData'=>$JsonArray),JSON_PRETTY_PRINT);
   }        
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant