douxiyi2418 2016-05-01 10:47
浏览 37
已采纳

我需要拒绝从Cordova先前的应用程序版本登录到我的服务器

I have made an app in javascript using Apache Cordova, and now i´m gonna use a new one written in java.

my app communicates with a php webservice, so, what are my options to deny the previous app to login ?

  1. I think one option may be versioning the new one and consulting it for every time that a login its requested.

but at the moment, I don't know ..

note: the previous app is distributed via email to the workers so I can't just update from a server and replace it.

  • 写回答

2条回答 默认 最新

  • duanran3115 2016-05-01 10:55
    关注

    You could have your Java client add a header when talking to your webservice, possibly a specific user agent. Or have it send a accept header which includes a version:

    GET /jobs HTTP/1.1
    Host: api.example.com
    Accept: application/vnd.example.api+json;version=2
    

    Your webservice can check the presence of the Accept header and the version string in it and decide what to do based on that.

    You could return a value that is compatible with the old client and a different value that is compatible with the new client. or you can simply return a 404 or a 501 status code with an error message to the old client.

    The generic process is explained here in detail:

    Applying this to PHP and Java is relatively simple:

    As an alternative you can add a version value to your request using a post variable, querystring parameter or as part of the request body (in JSON). I personally like it less than the use of accept headers, since the last is more flexible in the long run. You can even add multiple values to an accept header to indicate which versions you support. Your server can reply with the version it responded with. Giving you a better long-term solution.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog