public function testNonceDoesntEverMatch() { $this->assertNotEmpty(Crypto::nonce()); $i = 30; while ($i--) { $this->assertNotEquals(Crypto::nonce(), Crypto::nonce()); } }
public function testPostEmailReturnsErrorOnUnmatchableEmailAndNinjaName() { $req = Request::create('/password/post_email'); $req->setMethod('POST'); $req->request->set('email', 'unmatchable@' . Crypto::nonce() . 'com'); $req->request->set('ninja_name', 'nomatch' . Crypto::nonce()); RequestWrapper::inject($req); $controller = new PasswordController(); $response = $controller->postEmail($this->m_dependencies); $this->assertInstanceOf(RedirectResponse::class, $response); $expected = 'unable to find a matching account'; $this->assertTrue(stripos($response->getTargetUrl(), rawurlencode($expected)) !== false, 'Url Redirection for [' . $response->getTargetUrl() . '] did not contain expected error string of [' . $expected . ']'); }
/** * Generate a full password reset request for an account * * @param Account $account * @return PasswordResetRequest */ public static function generate(Account $account, $nonce = null) { $nonce = $nonce !== null ? $nonce : Crypto::nonce(); return self::create(['_account_id' => $account->id(), 'nonce' => $nonce]); }