Adobe Air 应用程序的 cakephp 用户身份验证
我有一个使用 flex 和 cakephp 开发的网络应用程序。我的客户需要使用 Adobe Air 制作该 Web 应用程序的桌面应用程序。柔性到空气的转换已成功完成。在 Flex 应用程序中,Flex 和 cakephp 的通信是使用远程控制器进行处理的。
在空中应用程序中,我在使用 cakephp 默认用户身份验证来验证用户身份时遇到问题。谁能帮我找到解决方案?
I have a web application developed using flex and cakephp. My client need to make a desktop application of that web application using Adobe Air. The conversion of the flex to Air is done successfully. I the flex application the communication of flex and cakephp is handled using a remotes controller.
In air application I have a problem of authenticating the user with cakephp default user authentication. Can anyone help me to find a solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您通过 POST 将用户凭据发送到 cakephp 后端。
UsersController 中的登录函数看起来像这样:
i suggest you to send your user credentials via POST to your cakephp backend.
A login function in your UsersController would look something like this:
基本上,您希望将验证请求作为 ajax 请求发送。为此,您需要修改标头、通过 cookie 捕获会话 ID 并将其发布以保持会话处于活动状态。它需要从 Cake 返回一个 JSON 对象。
我创建了几个 Flex 类,用于为 Flex 移动应用程序和 CakePHP 后端实现此目的。它应该能够满足您的需求。
它位于两个文件中,AutoValidationUrlRequest.as 扩展了 HeaderURLRequest.as 文件。我并不乐观,但可能有几个变量需要改变,但总的来说,它运行得很好,并且可能只需要进行几个更改就可以在您的应用程序上运行。
要使用它,只需创建一个新的 AutoValidationUrlRequest 对象并在 headerUrlRequestComplete 事件上添加一个事件侦听器,然后运行 AutoValidationUrlRequest.send(...) 进行 POST。还有一个名为convertToPostVars的方便方法,用于简单的Cake Friends Post变量。
AutoValidationUrlRequest.as:
HeaderURLRequest.as:
另外,将其与我的 Jose Gonzalez 的 CakePHP ajax_controller 插件的分叉版本 一起使用是真的很方便。它基本上接受任何 Ajax 请求并转换所有视图变量并将它们输出到 JSON 对象,而不渲染视图。否则,如果您不使用 ajax 请求,Cake 将正常渲染视图。祝你好运!
Basically, you want to send the validation request as an ajax request. To do that you need to modify headers, capture session ids through cookies and post them to keep the session alive. It expects a JSON object returned from Cake.
I've created a couple Flex classes that achieve just this for a Flex Mobile App and a CakePHP backend. It should work the same for your needs.
It's in two files, the AutoValidationUrlRequest.as extends the HeaderURLRequest.as file. I'm not positive but there may be a couple variables to change, but overall it works very well and probably won't take more than a couple changes to get it working on your app.
To use it, simply create a new AutoValidationUrlRequest object and add an event listener on the headerUrlRequestComplete Event and then run AutoValidationUrlRequest.send(...) to POST. there is also a handy method called convertToPostVars for easy Cake Friendly Post variables.
AutoValidationUrlRequest.as:
HeaderURLRequest.as:
Also, using this with my forked version of Jose Gonzalez's CakePHP ajax_controller plugin is really handy. It basically takes any Ajax Request and converts all view variables and outputs them into a JSON object, no rendered view. Otherwise, if you're not using an ajax request, Cake will render the views normally. Good Luck!