fix(auth): fix function validate confirm password

This commit is contained in:
arieeefajar 2025-05-14 14:12:50 +07:00
parent a2b1045187
commit 23894e0978
3 changed files with 36 additions and 1 deletions

1
.phpunit.result.cache Normal file
View File

@ -0,0 +1 @@
{"version":1,"defects":{"Tests\\Unit\\CertaintyFactorTest::test_cf_combination_opposite_signs":7,"Tests\\Feature\\Auth\\AuthenticationTest::test_login_screen_can_be_rendered":8,"Tests\\Feature\\Auth\\AuthenticationTest::test_users_can_authenticate_using_the_login_screen":8,"Tests\\Feature\\Auth\\AuthenticationTest::test_users_can_not_authenticate_with_invalid_password":8,"Tests\\Feature\\Auth\\AuthenticationTest::test_users_can_logout":8,"Tests\\Feature\\Auth\\EmailVerificationTest::test_email_verification_screen_can_be_rendered":8,"Tests\\Feature\\Auth\\EmailVerificationTest::test_email_can_be_verified":8,"Tests\\Feature\\Auth\\EmailVerificationTest::test_email_is_not_verified_with_invalid_hash":8,"Tests\\Feature\\Auth\\PasswordConfirmationTest::test_confirm_password_screen_can_be_rendered":8,"Tests\\Feature\\Auth\\PasswordConfirmationTest::test_password_can_be_confirmed":8,"Tests\\Feature\\Auth\\PasswordConfirmationTest::test_password_is_not_confirmed_with_invalid_password":8,"Tests\\Feature\\Auth\\PasswordResetTest::test_reset_password_link_screen_can_be_rendered":8,"Tests\\Feature\\Auth\\PasswordResetTest::test_reset_password_link_can_be_requested":8,"Tests\\Feature\\Auth\\PasswordResetTest::test_reset_password_screen_can_be_rendered":8,"Tests\\Feature\\Auth\\PasswordResetTest::test_password_can_be_reset_with_valid_token":8,"Tests\\Feature\\Auth\\PasswordUpdateTest::test_password_can_be_updated":8,"Tests\\Feature\\Auth\\PasswordUpdateTest::test_correct_password_must_be_provided_to_update_password":8,"Tests\\Feature\\Auth\\RegistrationTest::test_registration_screen_can_be_rendered":8,"Tests\\Feature\\Auth\\RegistrationTest::test_new_users_can_register":8,"Tests\\Feature\\ProfileTest::test_profile_page_is_displayed":8,"Tests\\Feature\\ProfileTest::test_profile_information_can_be_updated":8,"Tests\\Feature\\ProfileTest::test_email_verification_status_is_unchanged_when_the_email_address_is_unchanged":8,"Tests\\Feature\\ProfileTest::test_user_can_delete_their_account":8,"Tests\\Feature\\ProfileTest::test_correct_password_must_be_provided_to_delete_account":8,"Tests\\Unit\\StoreEvaluationTest::test_store_saves_evaluation_successfully":8},"times":{"Tests\\Unit\\CertaintyFactorTest::test_cf_positive_combination":0.009,"Tests\\Unit\\CertaintyFactorTest::test_cf_negative_combination":0,"Tests\\Unit\\CertaintyFactorTest::test_cf_combination_opposite_signs":0.001,"Tests\\Unit\\ExampleTest::test_that_true_is_true":0.031,"Tests\\Feature\\ExampleTest::test_the_application_returns_a_successful_response":5.614,"Tests\\Unit\\StoreEvaluationTest::test_store_saves_evaluation_successfully":1.869}}

View File

@ -69,12 +69,16 @@ public function createNewPasswordForm(Request $request)
public function storeNewPasswordForm(Request $request)
{
$data = DB::table('password_reset_tokens')->where('email', $request->email)->first();
if ($data == null || !Hash::check($request->token, $data->token)) {
toast('Link reset password tidak valid atau kedaluwarsa', 'error')->position('top')->autoclose(3000);
return redirect()->back();
}
if ($request->new_password != $request->confirm_password) {
toast('Konfirmasi Password tidak cocok', 'error')->position('top')->autoclose(3000);
return redirect()->back();
}
DB::beginTransaction();
$user = User::where('email', $request->email)->first();
$user->password = Hash::make($request->new_password);

View File

@ -0,0 +1,30 @@
<?php
namespace Tests\Unit;
use App\Http\Controllers\AssesmentFormController;
use PHPUnit\Framework\TestCase;
class CertaintyFactorTest extends TestCase
{
public function test_cf_positive_combination()
{
$controller = new AssesmentFormController();
$result = $controller->calculateCFc(0.6, 0.4);
$this->assertEquals(0.76, $result);
}
public function test_cf_negative_combination()
{
$controller = new AssesmentFormController();
$result = $controller->calculateCFc(-0.6, -0.4);
$this->assertEquals(-0.76, $result);
}
public function test_cf_combination_opposite_signs()
{
$controller = new AssesmentFormController();
$result = $controller->calculateCFc(0.6, -0.4);
$this->assertEqualsWithDelta(0.333, $result, 0.001);
}
}