Skip to content

Commit

Permalink
fix: password forgot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseekn committed Mar 23, 2022
1 parent ef83a93 commit 70c845d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/Http/Actions/UserActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public static function update(array $data, string $email)

return $user;
}

public static function updatPassword(string $password, string $email)
{
return self::update(['password' => $password], $email);
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public function reset(Request $request, Response $response)
$response->redirect()->to("password/new?email={$request->email}")->go();
}

public function update(Request $request, Response $response)
public function update(Request $request, Response $response, LoginValidator $loginValidator)
{
LoginValidator::make($request->inputs())->redirectBackOnFail($response);
$user = UserActions::update(['password' => $request->password], $request->email);
$loginValidator->validate($request->inputs());
$user = UserActions::updatPassword($request->password, $request->email);

if (!$user) {
Alert::default(__('password_not_reset'))->error();
Expand Down
1 change: 1 addition & 0 deletions core/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
class Model
{
public $id;
public static $table = '';

public function __construct(string $table, $data = null)
Expand Down
8 changes: 4 additions & 4 deletions tests/Application/Auth/PasswordForgotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* @link https://github.com/eliseekn/tinymvc
*/

use App\Database\Factories\TokenFactory;
use App\Database\Factories\UserFactory;
use App\Database\Models\Token;
use App\Database\Models\User;
use Core\Support\Encryption;
use App\Database\Models\User;
use App\Database\Models\Token;
use Core\Testing\ApplicationTestCase;
use App\Database\Factories\UserFactory;
use App\Database\Factories\TokenFactory;
use Core\Testing\Concerns\RefreshDatabase;

class PasswordForgotTest extends ApplicationTestCase
Expand Down

0 comments on commit 70c845d

Please sign in to comment.