fixed security of users
This commit is contained in:
parent
27bc56bc7f
commit
2002092458
8 changed files with 67 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.uottawa.olympus.olympusservices;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
@ -34,4 +35,13 @@ public class AdminWelcome extends AppCompatActivity {
|
|||
gridView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed(){
|
||||
}
|
||||
|
||||
public void LogOut(View view){
|
||||
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,13 @@ public class LogIn extends AppCompatActivity {
|
|||
if(user.getRole()=="Admin"){
|
||||
Intent intent = new Intent(getApplicationContext(),AdminWelcome.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
else {
|
||||
Intent intent = new Intent(getApplicationContext(),Welcome.class);
|
||||
intent.putExtra("username", username);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +54,12 @@ public class LogIn extends AppCompatActivity {
|
|||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed(){
|
||||
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,13 +20,15 @@ public class Main extends AppCompatActivity {
|
|||
|
||||
public void onClickSignUp(View view){
|
||||
Intent intent = new Intent(getApplicationContext(),SignUp.class);
|
||||
startActivityForResult(intent,0);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
public void onClickLogIn(View view){
|
||||
Intent intent = new Intent(getApplicationContext(),LogIn.class);
|
||||
startActivityForResult(intent,0);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ public class SignUp extends AppCompatActivity {
|
|||
Snackbar.make(view, "Clicked " + item, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void onClickSignUp(View view){
|
||||
|
@ -33,7 +34,7 @@ public class SignUp extends AppCompatActivity {
|
|||
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
||||
//TODO add message conditional to check if every EditText is filled up to standards
|
||||
if(username.length()>=5 && password.length()>5 && firstname.length()>0 && lastname.length()>0 && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*")
|
||||
&& firstname.matches("[a-zA-Z0-9]*") && lastname.matches("[a-zA-Z0-9]*")){
|
||||
&& firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){
|
||||
switch(spinner.getText().toString()){
|
||||
case "User":
|
||||
newUser = new User(username,password,firstname,lastname);
|
||||
|
@ -50,7 +51,8 @@ public class SignUp extends AppCompatActivity {
|
|||
DBHelper dbHelper = new DBHelper(this);
|
||||
Intent intent = new Intent(getApplicationContext(),LogIn.class); //TODO check if signup should take to the login page or automatically login
|
||||
if(dbHelper.addUser(newUser)){
|
||||
startActivityForResult(intent,0);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}else{
|
||||
Toast.makeText(this,"Username is taken",Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -59,13 +61,17 @@ public class SignUp extends AppCompatActivity {
|
|||
Toast.makeText(this, "Fields cannot be empty", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else if (username.length()<=5 || password.length()<=5 ){
|
||||
Toast.makeText(this, "Password and username must be longer than 5 characters", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(this, "Password and username must be longer than 4 characters", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else{
|
||||
Toast.makeText(this, "Fields may only contain alphanumeric values", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed(){
|
||||
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,14 @@ public class Welcome extends AppCompatActivity {
|
|||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed(){
|
||||
}
|
||||
public void LogOut(View view){
|
||||
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue