【发布时间】:2014-12-22 13:09:23
【问题描述】:
为了登录,我正在做类似的事情:
function setHeader(xhr) {
// as per HTTP authentication spec [2], credentials must be
// encoded in base64. Lets use window.btoa [3]
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ':' + password));
}
$.ajax({type: "POST", url: AUTH_URL, beforeSend: setHeader}).
fail(function(resp){
console.log('bad credentials.')
}).
done(function(resp){
});
之后,我将会话存储在本地存储中。
但是,对于注销,我无法弄清楚如何使用此会话与请求标头一起发送,因此 django 的:request.logout() 注销具有该会话 ID 的用户
【问题讨论】:
标签: javascript django django-rest-framework django-users django-sessions