Ejemplo n.º 1
0
 public function testPostResetWithInvalidatedTokenYeildsError()
 {
     $token = '34838383838';
     PasswordResetRequest::generate($this->account, $token);
     $request = Request::create('/resetpassword.php');
     $request->setMethod('POST');
     $request->request->set('token', $token);
     $password = '******';
     $request->request->set('new_password', $password);
     $request->request->set('password_confirmation', $password);
     $request->request->set('email', $this->account->getActiveEmail());
     // Invalidate the token
     PasswordResetRequest::where('_account_id', '=', $this->account->id())->update(['used' => true]);
     // Now run the controller method to reset!
     $controller = new PasswordController();
     $response = $controller->postReset($request);
     $this->assertTrue(stripos($response->getTargetUrl(), url('Token was invalid')) !== false, 'Url was [' . $response->getTargetUrl() . '] instead of expected not long enough password error url.');
     // Password should be changed.
     $this->assertFalse($this->checkTestPasswordMatches($password), 'Password should not have been changed on a rejection!');
 }
Ejemplo n.º 2
0
Eventual route definitions
   'resetpassword' => [
       'type'    => 'controller',
       'actions' => [
           'email'      => 'postEmail',
           'reset'      => 'getReset',
           'post_reset' => 'postReset',
       ],
   ],
*/
use NinjaWars\core\control\PasswordController;
use NinjaWars\core\data\PasswordResetRequest;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
$command = (string) in('command');
$controller = new PasswordController();
$request = Request::createFromGlobals();
switch (true) {
    case $command == 'post_reset':
        $response = $controller->postReset($request);
        break;
    case $command == 'reset':
        $response = $controller->getReset($request);
        break;
    case $command == 'email':
        $response = $controller->postEmail($request);
        break;
    default:
        $command == 'index';
        $response = $controller->index($request);
        break;