Commit a6e15b2a authored by chris.crook's avatar chris.crook

> login button pretty much done

parent 80b671f6
...@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -57,7 +58,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -57,7 +58,7 @@ public class MainActivity extends AppCompatActivity {
if (tempload.equals("&&&")){ if (tempload.equals("&&&")){
// this means that the load failed // this means that the load failed
} }
else{ /*else{
// load successful // load successful
if (tempload.equals("")){ if (tempload.equals("")){
// dont add a '#' to the start // dont add a '#' to the start
...@@ -88,7 +89,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -88,7 +89,7 @@ public class MainActivity extends AppCompatActivity {
System.out.println(tempint + ""); System.out.println(tempint + "");
} }
System.out.println(tempint); System.out.println(tempint);
} }*/
} }
...@@ -101,7 +102,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -101,7 +102,7 @@ public class MainActivity extends AppCompatActivity {
while (reader.hasNextLine()){ while (reader.hasNextLine()){
temp = temp + reader.nextLine(); temp = temp + reader.nextLine();
} }
Toast.makeText(getApplicationContext(), temp + " ", Toast.LENGTH_LONG).show(); //Toast.makeText(getApplicationContext(), temp + " ", Toast.LENGTH_LONG).show();
return temp; return temp;
} catch(Exception e){ } catch(Exception e){
Toast.makeText(getApplicationContext(), "read error", Toast.LENGTH_LONG).show(); Toast.makeText(getApplicationContext(), "read error", Toast.LENGTH_LONG).show();
...@@ -154,11 +155,14 @@ public class MainActivity extends AppCompatActivity { ...@@ -154,11 +155,14 @@ public class MainActivity extends AppCompatActivity {
// load successful // load successful
if (tempload.equals("")){ if (tempload.equals("")){
// dont add a '#' to the start // dont add a '#' to the start
tempload += "adminname&adminuser&adminpassword&ADMIN";
tempload += "%examplename&exampleuser&examplepassword&USER";
} }
else{ else{
tempload += "#"; tempload += "%";
tempload += "adminname&adminuser&adminpassword&ADMIN";
tempload += "%examplename&exampleuser&examplepassword&USER";
} }
tempload += "adminname&adminuser&adminpassword&ADMIN";
String [] temploadarray = tempload.split("%"); String [] temploadarray = tempload.split("%");
size = temploadarray.length; size = temploadarray.length;
for (int i = 0; i < size; i++){ for (int i = 0; i < size; i++){
...@@ -181,7 +185,47 @@ public class MainActivity extends AppCompatActivity { ...@@ -181,7 +185,47 @@ public class MainActivity extends AppCompatActivity {
System.out.println(tempint + ""); System.out.println(tempint + "");
} }
System.out.println(tempint); System.out.println(tempint);
System.out.println("RAW DATA: " + magicwords [0] [0] + " NAME: " + magicwords [0] [1] + " USERNAME: " + magicwords [0] [2] + " PASSWORD: " + magicwords [0] [3] + " ADMIN FLAG: " + magicwords [0] [4]); /*for (int i = 0 ; i < 10; i++){
System.out.println(i);
System.out.println(">RAW DATA: " + magicwords [i] [0] + " >NAME: " + magicwords [i] [1] + " >USERNAME: " + magicwords [i] [2] + " >PASSWORD: " + magicwords [i] [3] + " >ADMIN FLAG: " + magicwords [i] [4]);
}*/
String euser = ((EditText) findViewById(R.id.username_input)).getText().toString();
String epass = ((EditText) findViewById(R.id.password_input)).getText().toString();
if (euser.equals("")){
Toast.makeText(getApplicationContext(), "Enter a valid Username", Toast.LENGTH_SHORT).show();
return;
}
if (epass.equals("")){
Toast.makeText(getApplicationContext(), "Enter a valid Password", Toast.LENGTH_SHORT).show();
return;
}
boolean wasthereausername = false;
for (int i = 0; i < sizeoverride; i++){
if (euser.equals(magicwords [i] [2])){
// username exists
if (epass.equals(magicwords [i] [3])){
// login is verified
if (magicwords [i] [4].equals("ADMIN")){
// user is an admin
Toast.makeText(getApplicationContext(), "Signed in as admin", Toast.LENGTH_SHORT).show();
return;
}
else{
Toast.makeText(getApplicationContext(), "Signed in as user", Toast.LENGTH_SHORT).show();
return;
}
}
else{
wasthereausername = true;
}
}
}
if (wasthereausername){
Toast.makeText(getApplicationContext(), "Login details invalid (password)", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getApplicationContext(), "Login details invalid (username)", Toast.LENGTH_SHORT).show();
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment