Hi experts!
I am implementing logout from my web application, using the POST logoutMethod I have managed to get it to logout, but after logout sometimes it redirects me directly to the form to login and sometimes it shows me the logout.html page, from there I don't understand the behavior, but the biggest problem is than when I log in again the logout.html page is dispalyed instead of the index.html page.
I have configured my xs-app.json file as follows.
the directory of the logout.html file is.
webapp/logout.html
{
"welcomeFile": "/index.html",
"authenticationMethod": "route",
"logout": {
"logoutEndpoint": "/do/logout",
"logoutPage": "/logout.html",
"logoutMethod": "POST",
"csrfProtection": true
},
"routes": [
{
"source": "^/resources/(.*)$",
"target": "/resources/$1",
"authenticationType": "none",
"destination": "ui5"
},
{
"source": "^/test-resources/(.*)$",
"target": "/test-resources/$1",
"authenticationType": "none",
"destination": "ui5"
},
{
"source": "^(/.*)",
"target": "$1",
"service": "html5-apps-repo-rt",
"authenticationType": "xsuaa"
}
]
}
In my controller I have these twos funcitons:
getToken: async function(){
return new Promise((resolve) => {
jQuery.ajax({
type: "GET",
url: 'do/logout',
headers: {
"X-CSRF-Token": 'fetch',
contentType: "application/json",
},
success: function(data, textStatus, request){
resolve(request.getResponseHeader('X-CSRF-Token'));
},
});
});
}
logout: async function(){
const token = await this.getToken();
jQuery.ajax({
type: "POST",
url: "do/logout",
headers: {
"X-CSRF-Token": token,
contentType: "application/json",
},
success: function (data) {
window.location.href = data;
// window.location.replace(data, false);
},
error: function (error) {
MessageToast.show(error);
},
});
}
I appreciate the comments that can help me solve this problem, thank you very much.