jQuery Mobile的 - 用户登录的最佳实践 [英] JQuery Mobile - User Login Best Practice

查看:202
本文介绍了jQuery Mobile的 - 用户登录的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建设使用jQuery Mobile移动接口一个已经存在的web应用程序需要用户认证,我不能在最好的办法满足于实现一个登录过程。

I'm building a mobile interface with JQuery Mobile for an already existing web app which requires user authentication, and I cannot settle on the best approach for implementing a login process.

我不那么在意服务器端验证,而是如何实现它的用户侧。

I'm not so concerned about the server side authentication, but rather how to implement it on the user side.

一些试验后,似乎有三种选择:

After some experimenting, it seems that the options are:


  1. 标准形式POST \\重定向提交:结果
    -disable自动阿贾克斯与数据AJAX =FALSE结果
    - 用户提交,检查凭据在服务器,然后发送重定向到App成功或回失败的登录页面。

  1. Standard form submit with POST\redirect:
    -Disable automatic ajax with data-ajax="false"
    -User submits, check credentials at server, then send redirect to app on success or back to login page on failure.

阿贾克斯法 $。mobile.changePage 结果
通过Ajax结果 - 发送的用户名/ passwd文件
- 根据响应,无论是与 $添加应用程序的头版。mobile.changePage 或显示错误消息

Ajax method with $.mobile.changePage
-Send username/passwd via Ajax
-Based on response, either add front page of app with $.mobile.changePage or display error message

阿贾克斯法 window.location.replace 结果
-Similar到选项2,除非使用 window.location.replace 添加应用程序的头版

Ajax method with window.location.replace
-Similar to option 2, except use window.location.replace to add front page of app

阿贾克斯法POST;重定向只在登录失败结果
表单提交启用 - 保持阿贾克斯。结果
-on服务器端,以这样一种方式,如果表单字段设置,它仅执行与您的应用程序的入口页面结合你的用户认证功能。结果
-On成功登录后,返回应用程序的头版。结果
-On登录失败,重定向回到登录页面。结果
- 如果表单值都没有设置,检查用户是否被正确记录,然后返回到标准输出页面。如果没有登录,重定向回登录。

Ajax method with POST; redirect only on failed login
-Keep ajax enabled for form submissions.
-On the server side, combine your user authentication function with the entry page of your app in such a way that it only executes if the form fields are set.
-On successful login, return front page of the app.
-On failed login, redirect back to the login page.
-If the form values are not set, check if the user is properly logged in and then return the standard output page. If not logged in, redirect back to login.

一些注意事项:结果
- 它必须使用POST来避免登录数据附加到URL结果
-Maintaining正确的后退按钮功能,使导航是用户友好的似乎是一种比较棘手。结果
-I'd喜欢做的流程尽可能容易地用尽可能少的页面重新加载尽可能

Some considerations:
-It must use POST to avoid attaching login data to URL
-Maintaining correct back button functionality so that navigation is user friendly appears to be kind of tricky.
-I'd like to make the process flow as easily as possible with as few page reloads as possible

任何想法?

编辑:结果
我发现了一个方法4,这可能是最好的办法。它避免了从POST产生的后退按钮功能问题/重定向方法。如果用户在第一次尝试验证,平滑页过渡保持的整个时间。如果不是,则页过渡流将被连续成功登录后保持。此外,所有的JQM内置的错误处理功能仍然可用。


I found a 4th method, which may be the best approach. It avoids the back button functionality issues resulting from the POST/redirect method. If the user authenticates on the first attempt, the smooth page transition is maintained the entire time. If not, the page transition flow will be continuously maintained after successful a login. Furthermore, all of JQM's built in error handling features remain available.

推荐答案

基本上,根据需要的。

标准形式提交(1点)是一个非常明确的方式,但如果登录的失败后,需要重新加载页面的话,多个请求(一个用于登录检查,另一个用于页面级负载)是由&放大器;同时,需要填充回输入数据。

Standard form submit( Point 1) is a very clear cut way, but if login is failed, need to reload the page so, multiple requests( one for login-check, another for page-load) are made & also, need to populate back input data.

有关AJAXř一些优点 -

Some advantages for AJAX r-


  • 如果连接被关闭或网络故障,就可以显示正确无差错保持页面设计不变。在标准呈交的情况下,它会显示在用户点可能需要重新启动移动应用连接无差错。

  • If connection is closed or network failure, we can show proper error- keeping the page design intact. In case of standard submit- it will show connection error- in which point user may need to restart the mobile-app.

在今后使用中,如果我们强制用户登录查看网页内容,AJAX可以简单地做到这一点伎俩,迅速。因此,我们可以把那个登录框每-其中,&安培;登录用户,而无需中断当前的状态。

In future use, if we force user to login to view content of a page, AJAX can simply do that trick, quickly. So we can put that login-box every-where & log in user without interrupting current state.

这篇关于jQuery Mobile的 - 用户登录的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆