-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.x] Prevent user registration form saving
password_confirmation
(#…
…10228) Co-authored-by: Duncan McClean <[email protected]>
- Loading branch information
1 parent
725d9cf
commit 0b80430
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ | |
|
||
use Statamic\Facades\Blueprint; | ||
use Statamic\Facades\Parse; | ||
use Statamic\Facades\Role; | ||
use Statamic\Facades\User; | ||
use Statamic\Facades\UserGroup; | ||
use Statamic\Statamic; | ||
use Tests\NormalizesHtml; | ||
use Tests\PreventSavingStacheItemsToDisk; | ||
|
@@ -339,6 +341,35 @@ public function it_will_use_redirect_query_param_off_url() | |
$this->assertStringContainsString($expectedErrorRedirect, $output); | ||
} | ||
|
||
/** @test */ | ||
public function it_ensures_some_fields_arent_saved() | ||
{ | ||
UserGroup::make('client')->title('Client')->save(); | ||
Role::make('admin')->title('Admin')->save(); | ||
|
||
$this->assertNull(User::findByEmail('[email protected]')); | ||
$this->assertFalse(auth()->check()); | ||
|
||
$this | ||
->post('/!/auth/register', [ | ||
'email' => '[email protected]', | ||
'password' => 'chewbacca', | ||
'password_confirmation' => 'chewbacca', | ||
'groups' => ['client'], | ||
'roles' => ['admin'], | ||
'super' => true, | ||
]) | ||
->assertSessionHasNoErrors() | ||
->assertLocation('/'); | ||
|
||
$user = User::findByEmail('[email protected]'); | ||
|
||
$this->assertEquals($user->groups()->count(), 0); | ||
$this->assertEquals($user->roles()->count(), 0); | ||
$this->assertNull($user->get('super')); | ||
$this->assertNull($user->get('password_confirmation')); | ||
} | ||
|
||
private function useCustomBlueprint() | ||
{ | ||
$blueprint = Blueprint::make()->setContents([ | ||
|