From d7126ab739ba1f37d019aa92b736cf6688ee90c8 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Fri, 5 Aug 2022 13:33:56 +0100 Subject: [PATCH 001/193] Fix email deliverabilty error log, switched createIdentity method to protected instead of private --- src/Authentication/Actions/Email2FA.php | 17 ++++++++--------- src/Authentication/Actions/EmailActivator.php | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Authentication/Actions/Email2FA.php b/src/Authentication/Actions/Email2FA.php index 7c781f285..148c4413e 100644 --- a/src/Authentication/Actions/Email2FA.php +++ b/src/Authentication/Actions/Email2FA.php @@ -71,14 +71,13 @@ public function handle(IncomingRequest $request) // Send the user an email with the code helper('email'); - $return = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '') - ->setTo($user->email) - ->setSubject(lang('Auth.email2FASubject')) - ->setMessage(view(setting('Auth.views')['action_email_2fa_email'], ['code' => $identity->secret])) - ->send(); - - if ($return === false) { - throw new RuntimeException('Cannot send email for user: ' . $user->email); + $email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); + $email->setTo($user->email); + $email->setSubject(lang('Auth.email2FASubject')); + $email->setMessage(view(setting('Auth.views')['action_email_2fa_email'], ['code' => $identity->secret])); + + if ($email->send(false) === false) { + throw new RuntimeException('Cannot send email for user: ' . $user->email . ' '. $email->printDebugger(['headers'])); } return view(setting('Auth.views')['action_email_2fa_verify']); @@ -115,7 +114,7 @@ public function afterLogin(User $user): void $this->createIdentity($user); } - private function createIdentity(User $user): void + protected function createIdentity(User $user): void { /** @var UserIdentityModel $identityModel */ $identityModel = model(UserIdentityModel::class); diff --git a/src/Authentication/Actions/EmailActivator.php b/src/Authentication/Actions/EmailActivator.php index 1dcfb6aab..1853d55d8 100644 --- a/src/Authentication/Actions/EmailActivator.php +++ b/src/Authentication/Actions/EmailActivator.php @@ -41,14 +41,13 @@ public function show(): string // Send the email helper('email'); - $return = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '') - ->setTo($userEmail) - ->setSubject(lang('Auth.emailActivateSubject')) - ->setMessage(view(setting('Auth.views')['action_email_activate_email'], ['code' => $code])) - ->send(); - - if ($return === false) { - throw new RuntimeException('Cannot send email for user: ' . $user->email); + $email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); + $email->setTo($userEmail); + $email->setSubject(lang('Auth.emailActivateSubject')); + $email->setMessage(view(setting('Auth.views')['action_email_activate_email'], ['code' => $code])); + + if ($email->send(false) === false) { + throw new RuntimeException('Cannot send email for user: ' . $user->email . ' '. $email->printDebugger(['headers'])); } // Display the info page @@ -101,7 +100,7 @@ public function afterRegister(User $user): void $this->createIdentity($user); } - private function createIdentity(User $user): string + protected function createIdentity(User $user): string { /** @var UserIdentityModel $identityModel */ $identityModel = model(UserIdentityModel::class); From 61c2f714922d9d492d839880dcd03576837a5f04 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Fri, 5 Aug 2022 14:07:31 +0100 Subject: [PATCH 002/193] Run cs-fix --- src/Authentication/Actions/Email2FA.php | 2 +- src/Authentication/Actions/EmailActivator.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Authentication/Actions/Email2FA.php b/src/Authentication/Actions/Email2FA.php index 148c4413e..5c9e0e668 100644 --- a/src/Authentication/Actions/Email2FA.php +++ b/src/Authentication/Actions/Email2FA.php @@ -77,7 +77,7 @@ public function handle(IncomingRequest $request) $email->setMessage(view(setting('Auth.views')['action_email_2fa_email'], ['code' => $identity->secret])); if ($email->send(false) === false) { - throw new RuntimeException('Cannot send email for user: ' . $user->email . ' '. $email->printDebugger(['headers'])); + throw new RuntimeException('Cannot send email for user: ' . $user->email . ' ' . $email->printDebugger(['headers'])); } return view(setting('Auth.views')['action_email_2fa_verify']); diff --git a/src/Authentication/Actions/EmailActivator.php b/src/Authentication/Actions/EmailActivator.php index 1853d55d8..be5a46143 100644 --- a/src/Authentication/Actions/EmailActivator.php +++ b/src/Authentication/Actions/EmailActivator.php @@ -47,7 +47,7 @@ public function show(): string $email->setMessage(view(setting('Auth.views')['action_email_activate_email'], ['code' => $code])); if ($email->send(false) === false) { - throw new RuntimeException('Cannot send email for user: ' . $user->email . ' '. $email->printDebugger(['headers'])); + throw new RuntimeException('Cannot send email for user: ' . $user->email . ' ' . $email->printDebugger(['headers'])); } // Display the info page From 37ee410ea3069ae7a5de707de9e37f1286c06d6a Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sat, 6 Aug 2022 13:39:16 +0100 Subject: [PATCH 003/193] Added email error log for MagicLinkController --- src/Controllers/MagicLinkController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Controllers/MagicLinkController.php b/src/Controllers/MagicLinkController.php index d59309a08..ae413995f 100644 --- a/src/Controllers/MagicLinkController.php +++ b/src/Controllers/MagicLinkController.php @@ -90,13 +90,13 @@ public function loginAction() // Send the user an email with the code helper('email'); - $return = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '') - ->setTo($user->email) - ->setSubject(lang('Auth.magicLinkSubject')) - ->setMessage(view(setting('Auth.views')['magic-link-email'], ['token' => $token])) - ->send(); + $email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); + $email->setTo($user->email); + $email->setSubject(lang('Auth.magicLinkSubject')); + $email->setMessage(view(setting('Auth.views')['magic-link-email'], ['token' => $token])); - if ($return === false) { + if ($email->send(false) === false) { + log_message('error', $email->printDebugger(['headers'])); return redirect()->route('magic-link')->with('error', lang('Auth.unableSendEmailToUser', [$user->email])); } From 570377be72b36edcce4270fe4c6211d4b275b483 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sat, 6 Aug 2022 13:41:44 +0100 Subject: [PATCH 004/193] Show headers error in a new line instead of inline, returned the scope of createIdentity() to it's default, so it can be added as a separate PR --- src/Authentication/Actions/Email2FA.php | 4 ++-- src/Authentication/Actions/EmailActivator.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Authentication/Actions/Email2FA.php b/src/Authentication/Actions/Email2FA.php index 5c9e0e668..dedfd0b5c 100644 --- a/src/Authentication/Actions/Email2FA.php +++ b/src/Authentication/Actions/Email2FA.php @@ -77,7 +77,7 @@ public function handle(IncomingRequest $request) $email->setMessage(view(setting('Auth.views')['action_email_2fa_email'], ['code' => $identity->secret])); if ($email->send(false) === false) { - throw new RuntimeException('Cannot send email for user: ' . $user->email . ' ' . $email->printDebugger(['headers'])); + throw new RuntimeException('Cannot send email for user: ' . $user->email . '\n' . $email->printDebugger(['headers'])); } return view(setting('Auth.views')['action_email_2fa_verify']); @@ -114,7 +114,7 @@ public function afterLogin(User $user): void $this->createIdentity($user); } - protected function createIdentity(User $user): void + private function createIdentity(User $user): void { /** @var UserIdentityModel $identityModel */ $identityModel = model(UserIdentityModel::class); diff --git a/src/Authentication/Actions/EmailActivator.php b/src/Authentication/Actions/EmailActivator.php index be5a46143..a0c96b8b5 100644 --- a/src/Authentication/Actions/EmailActivator.php +++ b/src/Authentication/Actions/EmailActivator.php @@ -47,7 +47,7 @@ public function show(): string $email->setMessage(view(setting('Auth.views')['action_email_activate_email'], ['code' => $code])); if ($email->send(false) === false) { - throw new RuntimeException('Cannot send email for user: ' . $user->email . ' ' . $email->printDebugger(['headers'])); + throw new RuntimeException('Cannot send email for user: ' . $user->email . '\n' . $email->printDebugger(['headers'])); } // Display the info page @@ -100,7 +100,7 @@ public function afterRegister(User $user): void $this->createIdentity($user); } - protected function createIdentity(User $user): string + private function createIdentity(User $user): string { /** @var UserIdentityModel $identityModel */ $identityModel = model(UserIdentityModel::class); From 2d39f84afd6962d8e422b551ae8ab5011938177b Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sat, 6 Aug 2022 13:54:12 +0100 Subject: [PATCH 005/193] Run composer cs-fix --- src/Controllers/MagicLinkController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controllers/MagicLinkController.php b/src/Controllers/MagicLinkController.php index ae413995f..f7837bfcd 100644 --- a/src/Controllers/MagicLinkController.php +++ b/src/Controllers/MagicLinkController.php @@ -97,6 +97,7 @@ public function loginAction() if ($email->send(false) === false) { log_message('error', $email->printDebugger(['headers'])); + return redirect()->route('magic-link')->with('error', lang('Auth.unableSendEmailToUser', [$user->email])); } From 9fbdd0ac30749ca35cb5665ffef47ddb4a76dac1 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sun, 7 Aug 2022 18:03:34 +0100 Subject: [PATCH 006/193] Cleared the email since it is shared --- src/Helpers/email_helper.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Helpers/email_helper.php b/src/Helpers/email_helper.php index f2314b129..ba3bfea90 100644 --- a/src/Helpers/email_helper.php +++ b/src/Helpers/email_helper.php @@ -43,6 +43,9 @@ function emailer(array $overrides = []): Email /** @var Email $email */ $email = service('email'); + // Clear previous email states since this is shared + $email->clear(); + return $email->initialize($config); } } From e47e0841a0e5f3b46eb13392c7e66544474f41d5 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sun, 7 Aug 2022 18:18:30 +0100 Subject: [PATCH 007/193] Removed deprecated second param in forge's createTable method --- .../2020-12-28-223112_create_auth_tables.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php b/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php index c3c39acf5..53a17bcb1 100644 --- a/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php +++ b/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php @@ -22,7 +22,7 @@ public function up(): void ]); $this->forge->addPrimaryKey('id'); $this->forge->addUniqueKey('username'); - $this->forge->createTable('users', true); + $this->forge->createTable('users'); /* * Auth Identities Table @@ -46,7 +46,7 @@ public function up(): void $this->forge->addUniqueKey(['type', 'secret']); $this->forge->addKey('user_id'); $this->forge->addForeignKey('user_id', 'users', 'id', '', 'CASCADE'); - $this->forge->createTable('auth_identities', true); + $this->forge->createTable('auth_identities'); /** * Auth Login Attempts Table @@ -67,7 +67,7 @@ public function up(): void $this->forge->addKey(['id_type', 'identifier']); $this->forge->addKey('user_id'); // NOTE: Do NOT delete the user_id or identifier when the user is deleted for security audits - $this->forge->createTable('auth_logins', true); + $this->forge->createTable('auth_logins'); /* * Auth Token Login Attempts Table @@ -87,7 +87,7 @@ public function up(): void $this->forge->addKey(['id_type', 'identifier']); $this->forge->addKey('user_id'); // NOTE: Do NOT delete the user_id or identifier when the user is deleted for security audits - $this->forge->createTable('auth_token_logins', true); + $this->forge->createTable('auth_token_logins'); /* * Auth Remember Tokens (remember-me) Table @@ -105,7 +105,7 @@ public function up(): void $this->forge->addPrimaryKey('id'); $this->forge->addUniqueKey('selector'); $this->forge->addForeignKey('user_id', 'users', 'id', '', 'CASCADE'); - $this->forge->createTable('auth_remember_tokens', true); + $this->forge->createTable('auth_remember_tokens'); // Groups Users Table $this->forge->addField([ @@ -116,7 +116,7 @@ public function up(): void ]); $this->forge->addPrimaryKey('id'); $this->forge->addForeignKey('user_id', 'users', 'id', '', 'CASCADE'); - $this->forge->createTable('auth_groups_users', true); + $this->forge->createTable('auth_groups_users'); // Users Permissions Table $this->forge->addField([ @@ -127,7 +127,7 @@ public function up(): void ]); $this->forge->addPrimaryKey('id'); $this->forge->addForeignKey('user_id', 'users', 'id', '', 'CASCADE'); - $this->forge->createTable('auth_permissions_users', true); + $this->forge->createTable('auth_permissions_users'); } //-------------------------------------------------------------------- From ea9e40703d46008050df5e5f394782329410ac97 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 8 Aug 2022 11:07:46 +0900 Subject: [PATCH 008/193] chore: add github/release.yml --- .github/release.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/release.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..de6e982d9 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,23 @@ +changelog: + exclude: + authors: + - dependabot + categories: + - title: Breaking Changes + labels: + - 'breaking change' + - title: Fixed Bugs + labels: + - bug + - title: New Features + labels: + - 'new feature' + - title: Enhancements + labels: + - enhancement + - title: Refactoring + labels: + - refactor + - title: Others (Only for checking. Remove this category) + labels: + - "*" From 97bd786abce98a46d3fdbb3c9aef712f68ddaa00 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Mon, 8 Aug 2022 06:43:13 +0330 Subject: [PATCH 009/193] fix: translate field name in validate error for `RegisterController` --- src/Controllers/RegisterController.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Controllers/RegisterController.php b/src/Controllers/RegisterController.php index e00e803bc..00c873974 100644 --- a/src/Controllers/RegisterController.php +++ b/src/Controllers/RegisterController.php @@ -151,10 +151,22 @@ protected function getValidationRules(): array ); return setting('Validation.registration') ?? [ - 'username' => $registrationUsernameRules, - 'email' => $registrationEmailRules, - 'password' => 'required|strong_password', - 'password_confirm' => 'required|matches[password]', + 'username' => [ + 'label' => 'Auth.username', + 'rules' => $registrationUsernameRules, + ], + 'email' => [ + 'label' => 'Auth.email', + 'rules' => $registrationEmailRules, + ], + 'password' => [ + 'label' => 'Auth.password', + 'rules' => 'required|strong_password', + ], + 'password_confirm' => [ + 'label' => 'Auth.passwordConfirm', + 'rules' => 'required|matches[password]', + ], ]; } } From a941c4d51e81e12b64772d648be11e94100c3dab Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Mon, 8 Aug 2022 06:47:19 +0330 Subject: [PATCH 010/193] fix: translate field name in validate error for `MagicLinkController` --- src/Controllers/MagicLinkController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Controllers/MagicLinkController.php b/src/Controllers/MagicLinkController.php index d59309a08..e62f68d3e 100644 --- a/src/Controllers/MagicLinkController.php +++ b/src/Controllers/MagicLinkController.php @@ -191,7 +191,10 @@ private function recordLoginAttempt( protected function getValidationRules(): array { return [ - 'email' => config('AuthSession')->emailValidationRules, + 'email' => [ + 'label' => 'Auth.email', + 'rules' => config('AuthSession')->emailValidationRules, + ], ]; } } From 7092f7d7db7588cd9378e58549ab970c05448958 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Mon, 8 Aug 2022 06:59:32 +0330 Subject: [PATCH 011/193] fix: translate field name in validate error for `LoginController` --- src/Controllers/LoginController.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Controllers/LoginController.php b/src/Controllers/LoginController.php index 8042cd750..7e28554d6 100644 --- a/src/Controllers/LoginController.php +++ b/src/Controllers/LoginController.php @@ -70,9 +70,18 @@ public function loginAction(): RedirectResponse protected function getValidationRules(): array { return setting('Validation.login') ?? [ - //'username' => config('AuthSession')->usernameValidationRules, - 'email' => config('AuthSession')->emailValidationRules, - 'password' => 'required', + // 'username' => [ + // 'label' => 'Auth.username', + // 'rules' => config('AuthSession')->usernameValidationRules, + // ], + 'email' => [ + 'label' => 'Auth.email', + 'rules' => config('AuthSession')->emailValidationRules, + ], + 'password' => [ + 'label' => 'Auth.password', + 'rules' => 'required', + ], ]; } From 656e09819c4a952f83beb90dd492deede91eb869 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Mon, 8 Aug 2022 05:03:58 +0100 Subject: [PATCH 012/193] get new instance of emailer helper --- src/Helpers/email_helper.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Helpers/email_helper.php b/src/Helpers/email_helper.php index ba3bfea90..26d3f1ce5 100644 --- a/src/Helpers/email_helper.php +++ b/src/Helpers/email_helper.php @@ -41,10 +41,7 @@ function emailer(array $overrides = []): Email } /** @var Email $email */ - $email = service('email'); - - // Clear previous email states since this is shared - $email->clear(); + $email = service('email', false); return $email->initialize($config); } From 90955ea0a78ac303cffbf8da35ec023c5ebce84b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Mon, 8 Aug 2022 07:36:40 +0330 Subject: [PATCH 013/193] docs: update validation rules whit field label --- docs/customization.md | 60 ++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/docs/customization.md b/docs/customization.md index 84036cc1c..d6958710c 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -95,35 +95,47 @@ Shield has the following rules for registration: ```php [ - 'username' => [ - 'required', - 'max_length[30]', - 'min_length[3]', - 'regex_match[/\A[a-zA-Z0-9\.]+\z/]', - 'is_unique[users.username]', - ], - 'email' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]', - 'password' => 'required|strong_password', - 'password_confirm' => 'required|matches[password]', + 'username' => [ + 'label' => 'Auth.username', + 'rules' => 'required|max_length[30]|min_length[3]|regex_match[/\A[a-zA-Z0-9\.]+\z/]|is_unique[users.username]', + ], + 'email' => [ + 'label' => 'Auth.email', + 'rules' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]', + ], + 'password' => [ + 'label' => 'Auth.password', + 'rules' => 'required|strong_password', + ], + 'password_confirm' => [ + 'label' => 'Auth.passwordConfirm', + 'rules' => 'required|matches[password]', + ], ]; ``` If you need a different set of rules for registration, you can specify them in your `Validation` configuration (**app/Config/Validation.php**) like: ```php -//-------------------------------------------------------------------- -// Rules -//-------------------------------------------------------------------- -public $registration = [ - 'username' => [ - 'required', - 'max_length[30]', - 'min_length[3]', - 'regex_match[/\A[a-zA-Z0-9\.]+\z/]', - 'is_unique[users.username]', + //-------------------------------------------------------------------- + // Rules + //-------------------------------------------------------------------- + public $registration = [ + 'username' => [ + 'label' => 'Auth.username', + 'rules' => 'required|max_length[30]|min_length[3]|regex_match[/\A[a-zA-Z0-9\.]+\z/]|is_unique[users.username]', ], - 'email' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]', - 'password' => 'required|strong_password', - 'password_confirm' => 'required|matches[password]', -]; + 'email' => [ + 'label' => 'Auth.email', + 'rules' => 'required|max_length[254]|valid_email|is_unique[auth_identities.secret]', + ], + 'password' => [ + 'label' => 'Auth.password', + 'rules' => 'required|strong_password', + ], + 'password_confirm' => [ + 'label' => 'Auth.passwordConfirm', + 'rules' => 'required|matches[password]', + ], + ]; ``` From fed55fd742c46cf664cf56a6c12cd72d915ef669 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Tue, 9 Aug 2022 07:36:56 +0330 Subject: [PATCH 014/193] fix: show validate errors in `magic-link` --- src/Controllers/MagicLinkController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/MagicLinkController.php b/src/Controllers/MagicLinkController.php index e62f68d3e..b279f87c3 100644 --- a/src/Controllers/MagicLinkController.php +++ b/src/Controllers/MagicLinkController.php @@ -60,7 +60,7 @@ public function loginAction() // Validate email format $rules = $this->getValidationRules(); if (! $this->validate($rules)) { - return redirect()->route('magic-link')->with('error', lang('Auth.invalidEmail')); + return redirect()->route('magic-link')->with('errors', $this->validator->getErrors()); } // Check if the user exists From 7bc38cf745cd8aa3cc67d62679358fd50dce00d6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Tue, 9 Aug 2022 07:45:46 +0330 Subject: [PATCH 015/193] fix: update view of `magic_link_form` for show validate errors --- src/Views/magic_link_form.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Views/magic_link_form.php b/src/Views/magic_link_form.php index f0f38ffb9..35bfde4f1 100644 --- a/src/Views/magic_link_form.php +++ b/src/Views/magic_link_form.php @@ -9,9 +9,20 @@
- - - + + + + +
From 8036f92498a3b6178a8041611020ac3ed256a27f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Tue, 9 Aug 2022 08:55:43 +0330 Subject: [PATCH 016/193] test: check show validate errors in `MagicLink` --- tests/Authentication/MagicLinkTest.php | 4 +++- tests/Controllers/MagicLinkTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/Authentication/MagicLinkTest.php b/tests/Authentication/MagicLinkTest.php index 93602625d..233fee0dc 100644 --- a/tests/Authentication/MagicLinkTest.php +++ b/tests/Authentication/MagicLinkTest.php @@ -50,7 +50,9 @@ public function testMagicLinkSubmitNoEmail(): void ]); $result->assertRedirectTo(route_to('magic-link')); - $result->assertSessionHas('error', lang('Auth.invalidEmail')); + $expected = ['email' => 'The Email Address field is required.']; + + $result->assertSessionHas('errors', $expected); } public function testMagicLinkSubmitBadEmail(): void diff --git a/tests/Controllers/MagicLinkTest.php b/tests/Controllers/MagicLinkTest.php index 4ecbb45cf..956f2ccee 100644 --- a/tests/Controllers/MagicLinkTest.php +++ b/tests/Controllers/MagicLinkTest.php @@ -46,4 +46,15 @@ public function testAfterLoggedInNotAllowDisplayMagicLink() $result = $this->get('/login/magic-link'); $result->assertRedirectTo(config('Auth')->loginRedirect()); } + + public function testShowValidateErrorsInMagicLink() + { + $result = $this->post('/login/magic-link', [ + 'email' => 'foo@example', + ]); + + $expected = ['email' => 'The Email Address field must contain a valid email address.']; + + $result->assertSessionHas('errors', $expected); + } } From fc59afc2c838f873879cd1ead79a5b8b23b7e530 Mon Sep 17 00:00:00 2001 From: MitkoIT <71694441+MitkoIT@users.noreply.github.com> Date: Tue, 9 Aug 2022 11:55:19 +0200 Subject: [PATCH 017/193] Load an auth helper in ActionController --- src/Controllers/ActionController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/ActionController.php b/src/Controllers/ActionController.php index 359cfe266..895a515e0 100644 --- a/src/Controllers/ActionController.php +++ b/src/Controllers/ActionController.php @@ -16,7 +16,7 @@ class ActionController extends BaseController { protected ?ActionInterface $action = null; - protected $helpers = ['setting']; + protected $helpers = ['auth', 'setting']; /** * Perform an initial check if we have a valid action or not. From 2e0285af7621302290d2fd3ecab068b1d5fec507 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Wed, 10 Aug 2022 08:33:01 +0330 Subject: [PATCH 018/193] docs: remove unnecessary details of `CI4.1.x` --- docs/install.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/docs/install.md b/docs/install.md index c24eabe4e..7f6975c88 100644 --- a/docs/install.md +++ b/docs/install.md @@ -95,8 +95,6 @@ If you get `Specified key was too long` error: > php spark shield:setup ``` -2. If you are running CodeIgniter v4.1.x, go to *Manual Setup* 4. - ### Manual Setup There are a few setup items to do before you can start using Shield in @@ -139,21 +137,6 @@ This requires that all of your controllers extend the `BaseController`, but that service('auth')->routes($routes); ``` -4. (If you are running CodeIgniter v4.2.0 or higher you can skip this step). Add the new password validation rules -by editing `app/Config/Validation.php`: - -```php -use CodeIgniter\Shield\Authentication\Passwords\ValidationRules as PasswordRules; - -public $ruleSets = [ - Rules::class, - FormatRules::class, - FileRules::class, - CreditCardRules::class, - PasswordRules::class //