Add CSRF protection for cookie-authenticated requests
This commit is contained in:
@@ -258,9 +258,12 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const m = document.cookie.match('(^|;)\\s*csrf_token\\s*=\\s*([^;]+)');
|
||||
const csrf = m ? m.pop() : '';
|
||||
|
||||
const res = await fetch('/api/user/change-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf },
|
||||
body: JSON.stringify({
|
||||
old_password: current,
|
||||
new_password: nv
|
||||
|
||||
Reference in New Issue
Block a user