Skip to content

Commit

Permalink
allow nbf to be a future date when creating a token - closes #1698
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Oct 17, 2018
1 parent 1eac56e commit b860a4c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
18 changes: 1 addition & 17 deletions src/Claims/NotBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,13 @@

class NotBefore extends Claim
{
use DatetimeTrait {
validateCreate as commonValidateCreate;
}
use DatetimeTrait;

/**
* {@inheritdoc}
*/
protected $name = 'nbf';

/**
* {@inheritdoc}
*/
public function validateCreate($value)
{
$this->commonValidateCreate($value);

if ($this->isFuture($value)) {
throw new InvalidClaimException($this);
}

return $value;
}

/**
* {@inheritdoc}
*/
Expand Down
10 changes: 0 additions & 10 deletions tests/Claims/NotBeforeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@

class NotBeforeTest extends AbstractTestCase
{
/**
* @test
* @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException
* @expectedExceptionMessage Invalid value provided for claim [nbf]
*/
public function it_should_throw_an_exception_when_passing_a_future_timestamp()
{
new NotBefore($this->testNowTimestamp + 3600);
}

/**
* @test
* @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException
Expand Down
4 changes: 2 additions & 2 deletions tests/Validators/PayloadValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public function it_should_throw_an_exception_when_providing_an_expired_payload()

/**
* @test
* @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException
* @expectedExceptionMessage Invalid value provided for claim [nbf]
* @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException
* @expectedExceptionMessage Not Before (nbf) timestamp cannot be in the future
*/
public function it_should_throw_an_exception_when_providing_an_invalid_nbf_claim()
{
Expand Down

0 comments on commit b860a4c

Please sign in to comment.