新手问题 手动刷新页面为什么会出现 WWW-Authenticate 验证登录框?

return · June 12, 2017 · 2305 hits

浏览网页的时候偶尔会出现 WWW-Authenticate'的验证的登录框 有个问题不理解,我是直接刷新页面的,按道理是不会走 xml 请求,有没有方法避免这个问题?

代码如下:

def require_login
    if !User.current.logged?
      # Extract only the basic url parameters on non-GET requests
      if request.get?
        url = url_for(params)
      else
        url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
      end
      respond_to do |format|
        format.html { redirect_to signin_url }
        format.atom { redirect_to signin_url }
        format.xml  { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
        format.js   { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
        format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
      end
      return false
    end
    true
  end

主要是这个提示登陆弹框很丑,直接删掉

format.xml  { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
       format.js   { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
       format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }

会有影响吗?

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.