weixin_33716941 2013-10-03 19:35 采纳率: 0%
浏览 149

从<div>添加/删除<button>吗?

Objective

The goal is to provide features for inventory management for the authenticated users. Other visitors can consult the inventory only, and filter their findings.

Authentication

The authentication is through the ajaxSession() javascript function as described here.

  1. PHP / Ajax : How to show/hide DIV on $_SESSION variable value? (See answer)
  2. PHP: $_SESSION doesn't seem to get set. Any idea?

Now, the $.ajax() delegate gets the right answer from the PHP server. Now, I though of simply use CSS classes .hide and .show, but it doesn't seem to be a good idea for security reasons.

The ajaxSession() function

function ajaxSession(actionUrl) {
    $.ajax(function() {
        url: actionUrl
        success: function(authenticated) {
            if (authenticated == 'true') {
                // create buttons here.
            } else {
                // ensure to empty those div
            }
        }
    });
}

N.B. There are other members set in the $.ajax() call, but the important is there.

  • 写回答

3条回答 默认 最新

  • George_Fal 2013-10-03 19:41
    关注

    The security mechanisms should be implemented on the server side!

    There won't be a security vulnerability if you create some login-specific buttons in your JS. Just be sure that you don't output sensitive data from your backend (PHP) or that you perform any unauthorized operation (again from your backend).

    Always check on the server side (for each operation) that the user is authorized!
    Store the login state in a session or the like. Don't rely on a URL parameter like isLoggedIn=1 or POST data. They come from the client. Clients are always the untrusted parts in an application.

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作