Ejemplo n.º 1
0
 /**
  * @param ElementView $view
  * @return ElementView
  */
 public function buildView(ElementView $view = null)
 {
     $view = new ElementView();
     $view = parent::buildView($view);
     $this->setValue($this->tokenProvider->getToken($this->tokenId));
     // Setting the token value modifies the attributes and value properties
     $view->attributes = $this->attributes;
     $view->value = $this->value;
     return $view;
 }
Ejemplo n.º 2
0
 function it_should_update_token_after_failed_validation_when_the_option_is_set_to_true(TokenProvider $provider)
 {
     $tokenId = '_login_csrf_token';
     $token = 'e95b24c1586e4b3dbfadcdd85aee46e0';
     $this->beConstructedWith(['tokenProvider' => $provider, 'tokenId' => $tokenId, 'updateToken' => true]);
     $provider->isTokenValid($tokenId, $token)->willReturn(false);
     $provider->refreshToken($tokenId)->shouldBeCalled();
     $isValid = $this->isValid($token);
     $isValid->shouldBe(false);
     $this->getMessages()->shouldHaveCount(1);
 }
Ejemplo n.º 3
0
 /**
  * Refresh token if 'updateToken' flag is set to true
  */
 protected function refreshToken()
 {
     if ($this->updateToken) {
         $this->tokenProvider->refreshToken($this->tokenId);
     }
 }