-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add anti-csrf token for /revoke-session
- Loading branch information
1 parent
9fa12d4
commit b6b64d3
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Service } from "../definitions.js"; | ||
|
||
export class AntiCSRFService extends Service { | ||
/** | ||
* Request an anti-csrf token from the server | ||
* @return anti_csrf: string | ||
*/ | ||
async token () { | ||
const anti_csrf = await (async () => { | ||
const resp = await fetch( | ||
`${window.gui_origin}/get-anticsrf-token`,{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': 'Bearer ' + window.auth_token, | ||
} | ||
},) | ||
const { token } = await resp.json(); | ||
return token; | ||
})(); | ||
|
||
return anti_csrf; | ||
} | ||
} |