Commit d9b7029d authored by Ahmad Abi Mulya's avatar Ahmad Abi Mulya

try to fix login validation

parent f6bc1965
......@@ -48,6 +48,7 @@ public class ForgetPassword extends AppCompatActivity {
userViewModel.resetPassword(users.get(i).getId() , password);
binding.setLoading(false);
startActivity(new Intent(ForgetPassword.this, LoginActivity.class));
finish();
return;
}
}
......
......@@ -32,9 +32,7 @@ public class LoginActivity extends AppCompatActivity {
checkSession();
finish();
}
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(UserViewModel.class);
binding.btnLogin.setOnClickListener(view -> {
if(binding.etUsername.getText().toString().length() == 0 || binding.etPassword.getText().toString().length() == 0){
Toast.makeText(getApplicationContext(), "Please input Username and Password", Toast.LENGTH_SHORT).show();
......@@ -49,11 +47,9 @@ public class LoginActivity extends AppCompatActivity {
}
});
}
public void tvForgetPassword(View view) {
startActivity(new Intent(LoginActivity.this, ForgetPassword.class));
}
public void tvSignUpHere(View view) {
startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
}
......@@ -68,13 +64,11 @@ public class LoginActivity extends AppCompatActivity {
startActivity(new Intent(LoginActivity.this, MainActivity.class).putExtra(DATA_LOGIN, users.get(i).getFullName()).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
finish();
return;
} else if (!binding.etUsername.getText().toString().equals(users.get(i).getEmail())) {
binding.etUsername.setError("Email Not Found!");
} else if (!binding.etPassword.getText().toString().equals(users.get(i).getPassword())) {
binding.etPassword.setError("Password Wrong!");
}
}
Toast.makeText(LoginActivity.this, "User Not Found!", Toast.LENGTH_LONG).show();
binding.setLoading(false);
return;
});
}catch (Exception e){
e.printStackTrace();
......
......@@ -53,30 +53,6 @@
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilCrPw"
app:passwordToggleEnabled="true"
app:boxBackgroundColor="@color/white"
android:textColorHint="@color/grey"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tilEmail"
android:layout_marginTop="20dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
android:layout_marginBottom="@dimen/space_default">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etCrPw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Current Password"
android:imeOptions="actionNext"
android:inputType="text"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilNewPw"
app:passwordToggleEnabled="true"
......@@ -85,7 +61,7 @@
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tilCrPw"
app:layout_constraintTop_toBottomOf="@id/tilEmail"
android:layout_marginTop="20dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
......
......@@ -104,7 +104,7 @@
android:id="@+id/tvDontHaveAnAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginStart="50dp"
android:text="@string/dont_have_an_account"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/tvSignUpHere"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment