mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
User (truly) can no longer reaccess login-required pages through the back button v.2
This commit is contained in:
parent
56cd59351f
commit
901af2d1cf
@ -68,6 +68,11 @@ public class AuthManager {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void nullify() {
|
||||
email = null;
|
||||
password = null;
|
||||
}
|
||||
|
||||
public void setAuthSession(AuthSession toSet) {
|
||||
authSession = (AWSCognitoAuthSession) toSet;
|
||||
waiting = false;
|
||||
|
||||
@ -36,6 +36,15 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
private AppBarConfiguration mAppBarConfiguration;
|
||||
public static AuthManager am = new AuthManager();
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev == null) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -48,7 +57,6 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
public void run() {
|
||||
Intent intent = new Intent(MainActivity.this, SplashActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
@ -198,7 +206,6 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
am.signOutUser();
|
||||
Intent intent = new Intent(MainActivity.this, com.example.listify.ui.LoginPage.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
@ -10,6 +10,9 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
public static boolean showSplash = true;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -20,8 +23,8 @@ public class SplashActivity extends AppCompatActivity {
|
||||
public void run() {
|
||||
showSplash = false;
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
intent.putExtra("prev", "Splash");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@ -23,16 +23,20 @@ public class ForgotPasswordPage extends AppCompatActivity {
|
||||
String newPassword;
|
||||
String confirmNewPassword;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev != null && (prev.equals("Sign up") || prev.equals("Log in"))) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_forgotpswd);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -55,6 +59,7 @@ public class ForgotPasswordPage extends AppCompatActivity {
|
||||
am.changePassword(email);
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
TextView invalidCred = findViewById(R.id.textView6);
|
||||
invalidCred.setText("Password criteria not met. Please try again.");
|
||||
@ -74,10 +79,11 @@ public class ForgotPasswordPage extends AppCompatActivity {
|
||||
try {
|
||||
am.confirmPasswordReset(newPassword, code);
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
|
||||
intent.putExtra("prev", "Forgot password");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,21 +20,26 @@ public class LoginPage extends AppCompatActivity {
|
||||
private Button button2; //Forgot password button
|
||||
private Button button3; //Log in button
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev != null && (prev.equals("Sign up") || prev.equals("Forgot password"))) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginPage.this, SignupPage.class);
|
||||
intent.putExtra("prev", "Log in");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@ -44,6 +49,7 @@ public class LoginPage extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginPage.this, ForgotPasswordPage.class);
|
||||
intent.putExtra("prev", "Log in");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@ -61,10 +67,11 @@ public class LoginPage extends AppCompatActivity {
|
||||
try {
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||
intent.putExtra("prev", "Login");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch(Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
TextView invalidCred = findViewById(R.id.textView5);
|
||||
invalidCred.setText("Incorrect email or password. Please try again.");
|
||||
|
||||
@ -32,21 +32,26 @@ public class SignupPage extends AppCompatActivity {
|
||||
String password;
|
||||
String confirmPassword;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev != null && (prev.equals("Log in") || prev.equals("Forgot password"))) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_signup);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(SignupPage.this, LoginPage.class);
|
||||
intent.putExtra("prev", "Sign up");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@ -73,6 +78,7 @@ public class SignupPage extends AppCompatActivity {
|
||||
am.startSignUp(email, password);
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
TextView invalidCred = findViewById(R.id.textView3);
|
||||
invalidCred.setText("Invalid credentials. Please try again.");
|
||||
@ -93,10 +99,11 @@ public class SignupPage extends AppCompatActivity {
|
||||
am.confirmSignUp(code);
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
intent.putExtra("prev", "Sign up");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,6 @@ public class HomeFragment extends Fragment {
|
||||
emailIntent.putExtra(Intent.EXTRA_TEXT, "Hello, this email is to confirm that you have deleted your Listify account.");
|
||||
try {
|
||||
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
|
||||
getActivity().finish();
|
||||
Log.i("Finished sending email...", "");
|
||||
System.out.println("A");
|
||||
} catch (Exception e) {
|
||||
@ -87,9 +86,9 @@ public class HomeFragment extends Fragment {
|
||||
}*/
|
||||
|
||||
am.deleteUser(requestor);
|
||||
am.nullify();
|
||||
Intent intent = new Intent(getActivity(), com.example.listify.ui.LoginPage.class);
|
||||
startActivity(intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user