mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
User can now log out and also automatically gets logged in after signing up
This commit is contained in:
parent
8dd2f33b42
commit
fdf27b9e62
@ -19,6 +19,10 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
|||||||
private Button button1; //Log in page button
|
private Button button1; //Log in page button
|
||||||
private Button button2; //Sign up button
|
private Button button2; //Sign up button
|
||||||
|
|
||||||
|
String email;
|
||||||
|
String password;
|
||||||
|
String confirmPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -41,9 +45,9 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
|||||||
EditText passwordText = (EditText) findViewById(R.id.editTextTextPassword);
|
EditText passwordText = (EditText) findViewById(R.id.editTextTextPassword);
|
||||||
EditText confirmPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
EditText confirmPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
||||||
|
|
||||||
String email = emailText.getText().toString();
|
email = emailText.getText().toString();
|
||||||
String password = passwordText.getText().toString();
|
password = passwordText.getText().toString();
|
||||||
String confirmPassword = confirmPasswordText.getText().toString();
|
confirmPassword = confirmPasswordText.getText().toString();
|
||||||
|
|
||||||
if(!password.equals(confirmPassword)) {
|
if(!password.equals(confirmPassword)) {
|
||||||
TextView invalidCred = findViewById(R.id.textView3);
|
TextView invalidCred = findViewById(R.id.textView3);
|
||||||
@ -76,7 +80,8 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
|||||||
if(!cancel) {
|
if(!cancel) {
|
||||||
try {
|
try {
|
||||||
am.confirmSignUp(code);
|
am.confirmSignUp(code);
|
||||||
Intent intent = new Intent(SignupPage.this, LoginPage.class);
|
am.signIn(email, password);
|
||||||
|
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|||||||
@ -39,6 +39,12 @@ public class HomeFragment extends Fragment {
|
|||||||
toLoginPage.setOnClickListener(new View.OnClickListener() {
|
toLoginPage.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
try {
|
||||||
|
am.signOutUser();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Log.i("Authentication", e.toString());
|
||||||
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -68,7 +74,6 @@ public class HomeFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
am.deleteUser(requestor);
|
am.deleteUser(requestor);
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="40dp"
|
android:layout_marginBottom="40dp"
|
||||||
android:text="Log in"
|
android:text="Log out"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user