1 - an CActiveForm with enableAjaxValidation and validateOnSubmit = true
2 - a field of the form with a rule validated by ajax
3 - an accessControl rule to allow only logged in users
4 - now go to the form, disable cookies and submit form. The user should be sent to the login url but it isn’t.
This because of the validateOnSubmit that validates the ajax rule, the accessControl rule catches this but when it tries to redirect it can’t because the request was ajax.
Am I doing something wrong or is there some solution to this?
An ajax request is a separate call… think about it as opening the requested page in a new tab… there the login page appears… .but your page is not refreshed…
If you want to redirect to the login page you need to do it from the JS / AJAX code (in the success handler)…
To make this easier in the Yii 1.1.9, CWebUser->loginRequiredAjaxResponse is added… so you can set what you want to be returned in this case… so that you can check for this value in the ajax handler and act accordingly…