首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ajax头请求"X-openIDM-Reauth-Password“不起作用

Ajax头请求"X-openIDM-Reauth-Password“不起作用
EN

Stack Overflow用户
提问于 2017-07-03 12:44:58
回答 1查看 124关注 0票数 1

我有一个openIDM程序,当用户提交更新新密码时,它会显示"X-openIDM-Reauth- password“,其中包括我需要重新键入的旧密码。下面是openidm侧的屏幕截图。

所以,我有自己UI,我被javascript ajax端通过下面的ajax调用请求。

代码语言:javascript
复制
$.ajax({
        contentType: "application/json; charset=UTF-8",
        datatype: 'json',
        url: targetHost+"openidm/managed/user/"+userId,     
        xhrFields: {
            withCredentials: true,
        },
        headers: {
                    "X-Requested-With":"XMLHttpRequest" ,
                    "X-OpenIDM-Reauth-Password": oldPassword
                },
        crossDomain:true,

        data: JSON.stringify(data),
        type: 'PATCH',   
        success:function(result) {
            console.log("success");
            swal({
                title: updateSuccessMsgs.formSubmit.slogan,
                text: updateSuccessMsgs.formSubmit.success,
                type: "success"
            }, function() {
                window.location = "my-profile.html";
            });
        },
        error:function (error){
            sweetAlert(updateErrorMsgs.updateError.slogan, updateErrorMsgs.updateError.fail, "error");
            console.log(error);
        }
     });

它抛出了这个错误。

代码语言:javascript
复制
XMLHttpRequest cannot load http://localhost:9090/openidm/managed/user/09096425-4ff1-42d4-8a4d-3a6b5004afca. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

有人能给我解释一下原因吗?非常感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-03 13:12:38

我找到了解决方案。我尝试在servletfilter-cors.json中再添加一个值,如下所示。我在"allowedHeaders“中添加了"X-OpenIDM-Reauth-Password”的值,结果是成功。

代码语言:javascript
复制
{
    "classPathURLs" : [ ],
    "systemProperties" : { },
    "requestAttributes" : { },
    "scriptExtensions" : { },
    "initParams" : {
        "allowedOrigins" : "*",
        "allowedMethods" : "GET,POST,PUT,DELETE,PATCH",
        "allowedHeaders" : "accept,x-openidm-password,x-openidm-nosession,x-openidm-username,content-type,origin,X-OpenIDM-Reauth-Password,x-requested-with",
        "allowCredentials" : "true",
        "chainPreflight" : "false"
    },
    "urlPatterns" : [
        "/*"
    ],
    "filterClass" : "org.eclipse.jetty.servlets.CrossOriginFilter"
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44877968

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档