-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow reset password to activate user if user activation enabled
Since the reset password flow involves an email being sent to the user to confirm the password reset, this should satisfy user activation as well as the same requirement is met. Refs: #35 (comment)
- Loading branch information
1 parent
1522c91
commit 4212e31
Showing
5 changed files
with
95 additions
and
22 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Winter\User\Tests\Unit\Models; | ||
|
||
use Mockery; | ||
use Winter\User\Models\User; | ||
use Winter\User\Tests\UserPluginTestCase; | ||
|
||
class UserModelTest extends UserPluginTestCase | ||
{ | ||
public function testCanActivateUserOnPasswordResetIfUserActivationEnabled() | ||
{ | ||
$userMock = Mockery::mock(User::class)->makePartial(); | ||
$userMock->shouldReceive('isActivatedByUser')->andReturn(true); | ||
$userMock->shouldReceive('flushEventListeners')->andReturnNull(); | ||
|
||
$userMock->fill([ | ||
'name' => 'Some User', | ||
'email' => 'some@website.tld', | ||
'password' => 'changeme', | ||
]); | ||
$userMock->reset_password_code = '12345abcde'; | ||
$userMock->save(); | ||
|
||
// Attempt a password reset | ||
$this->assertTrue($userMock->attemptResetPassword('12345abcde', 'newpassword')); | ||
$this->assertTrue($userMock->is_activated); | ||
} | ||
|
||
public function testWontActivateUserOnPasswordResetIfUserActivationNotEnabled() | ||
{ | ||
$userMock = Mockery::mock(User::class)->makePartial(); | ||
$userMock->shouldReceive('isActivatedByUser')->andReturn(false); | ||
$userMock->shouldReceive('flushEventListeners')->andReturnNull(); | ||
|
||
$userMock->fill([ | ||
'name' => 'Some User', | ||
'email' => 'some@website.tld', | ||
'password' => 'changeme', | ||
]); | ||
$userMock->reset_password_code = '12345abcde'; | ||
$userMock->save(); | ||
|
||
// Attempt a password reset | ||
$this->assertTrue($userMock->attemptResetPassword('12345abcde', 'newpassword')); | ||
$this->assertFalse($userMock->is_activated); | ||
} | ||
} |