Skip to content

Commit

Permalink
Config to be able to customize the duration of the reset password req…
Browse files Browse the repository at this point in the history
…uests
  • Loading branch information
Zizaco committed Jul 20, 2014
1 parent e113fc5 commit b9081d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/Zizaco/Confide/EloquentPasswordService.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ protected function getOldestValidDate()
// Instantiate a carbon object (that is a dependency of
// 'illuminate/database')
$carbon = $this->app['Carbon\Carbon'];
$config = $this->app['config'];

return $carbon->now()
->subHours(7)
->subHours($config->get('confide::confide.password_reset_expiration', 7))
->toDateTimeString();
}
}
18 changes: 7 additions & 11 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,16 @@

/*
|--------------------------------------------------------------------------
| Signup (create) Cache
| Password reset expiration
|--------------------------------------------------------------------------
|
| By default you will only can only register once every 2 hours
| (120 minutes) because you are not able to receive a registration
| email more often then that.
|
| You can adjust that limitation here, set to 0 for no caching.
| Time is in minutes.
|
| By default. A password reset request will expire after 7 hours. With the
| line below you will be able to customize the duration of the reset
| requests here.
|
*/
'signup_cache' => 120,
'password_reset_expiration' => 7, // hours

/*
|--------------------------------------------------------------------------
| Signup E-mail and confirmation (true or false)
Expand All @@ -106,7 +102,7 @@
| signup_confirm:
| is to decide of a member needs to be confirmed before he is able to login
| so when you set this to true, then a member has to be confirmed before
| he is able to login, so if you want to use an IPN for confirmation, be
| he is able to login, so if you want to use an IPN for confirmation, be
| sure that the ipn process also changes the confirmed flag in the member
| table, otherwise they will not be able to login after the payment.
|
Expand Down
8 changes: 7 additions & 1 deletion tests/Zizaco/Confide/EloquentPasswordServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,12 @@ public function testShouldGetOldestValidDate()
*/
$oldestValidDate = '2014-07-16 22:20:26';
$carbon = m::mock('Carbon\Carbon');
$config = m::mock('Config');
$passService = m::mock('Zizaco\Confide\EloquentPasswordService');

$passService->shouldAllowMockingProtectedMethods();
$passService->app['Carbon\Carbon'] = $carbon;
$passService->app['config'] = $config;

/*
|------------------------------------------------------------
Expand All @@ -424,11 +426,15 @@ public function testShouldGetOldestValidDate()
$passService->shouldReceive('getOldestValidDate')
->passthru();

$config->shouldReceive('get')
->once()->with('confide::confide.password_reset_expiration', 7)
->andReturn(14);

$carbon->shouldReceive('now')
->once()->andReturn($carbon);

$carbon->shouldReceive('subHours')
->once()->with(7)
->once()->with(14)
->andReturn($carbon);

$carbon->shouldReceive('toDateTimeString')
Expand Down

0 comments on commit b9081d4

Please sign in to comment.