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