mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Finished with adding an extra security step to the delete account process
This commit is contained in:
parent
e1c670fed0
commit
a3ed7ba8d9
@ -60,6 +60,10 @@ public class AuthManager {
|
|||||||
return authSession.getUserPoolTokens().getValue().getIdToken();
|
return authSession.getUserPoolTokens().getValue().getIdToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAuthSession(AuthSession toSet) {
|
public void setAuthSession(AuthSession toSet) {
|
||||||
authSession = (AWSCognitoAuthSession) toSet;
|
authSession = (AWSCognitoAuthSession) toSet;
|
||||||
waiting = false;
|
waiting = false;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.example.listify.ui.home;
|
package com.example.listify.ui.home;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -8,6 +10,8 @@ import android.widget.Button;
|
|||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
@ -44,19 +48,42 @@ public class HomeFragment extends Fragment {
|
|||||||
toDeleteAccountPage.setOnClickListener(new View.OnClickListener() {
|
toDeleteAccountPage.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
try {
|
View passwordView = getLayoutInflater().inflate(R.layout.activity_code, null);
|
||||||
Properties configs = new Properties();
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
try {
|
builder.setView(passwordView);
|
||||||
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
builder.setTitle("Account deletion verification");
|
||||||
} catch (IOException | JSONException e) {
|
builder.setMessage("Are you sure you want to delete your account? If so, enter your password below and hit \"Yes\".");
|
||||||
e.printStackTrace();
|
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
EditText passwordText = (EditText) passwordView.findViewById(R.id.editTextCode);
|
||||||
|
String password = passwordText.getText().toString();
|
||||||
|
if(password.equals(am.getPassword())) {
|
||||||
|
try {
|
||||||
|
Properties configs = new Properties();
|
||||||
|
try {
|
||||||
|
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
|
am.deleteUser(requestor);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Log.i("Authentication", e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
});
|
||||||
am.deleteUser(requestor);
|
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
catch (Exception e) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Log.i("Authentication", e.toString());
|
return;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user