Support absolute redirects in the formcontroller

Supports absolute redirects being used in the FormController behaviour.

If the form_config.yaml specifies 
```twig
create:
    redirect: https://api.example.com/oauth/authorize
```
Then the behaviour will now properly redirect the user to the URL provided where previously it would redirect to a url along the lines of `october.example.com/backend/https://api.example.com/oauth/authorize`. Relative backend redirect URLs are unchanged.
This commit is contained in:
Luke Towers 2018-02-06 14:42:24 -06:00 committed by GitHub
parent a916d99de4
commit 9840ff228f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -467,7 +467,15 @@ class FormController extends ControllerBehavior
$redirectUrl = RouterHelper::parseValues($model, array_keys($model->getAttributes()), $redirectUrl);
}
return ($redirectUrl) ? Backend::redirect($redirectUrl) : null;
if (starts_with($redirectUrl, 'http://') || starts_with($redirectUrl, 'https://')) {
// Process absolute redirects
$redirect = Redirect::to($redirectUrl);
} else {
// Process relative redirects
$redirect = ($redirectUrl) ? Backend::redirect($redirectUrl) : null;
}
return $redirect;
}
/**