mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-12 18:58:00 +00:00
use cookie auth for frontend
This commit is contained in:
parent
50c323ba1e
commit
0f3b72830b
|
@ -1,15 +1,3 @@
|
|||
function get_cookie(name) {
|
||||
const regex = new RegExp(`(^| )` + name + `=([^;]+)`);
|
||||
const match = document.cookie.match(regex);
|
||||
|
||||
if (match) {
|
||||
return match[2]
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function get_date_string(date) {
|
||||
var year = date.getFullYear().toString();
|
||||
var month = date.getMonth().toString();
|
||||
|
@ -46,11 +34,6 @@ function append_table_row(table, row_name, row) {
|
|||
|
||||
|
||||
class Client {
|
||||
constructor() {
|
||||
this.token = get_cookie("user-token");
|
||||
}
|
||||
|
||||
|
||||
async request(method, path, body = null) {
|
||||
var headers = {
|
||||
"Accept": "application/json"
|
||||
|
@ -61,10 +44,6 @@ class Client {
|
|||
body = JSON.stringify(body)
|
||||
}
|
||||
|
||||
if (this.token !== null) {
|
||||
headers["Authorization"] = "Bearer " + this.token;
|
||||
}
|
||||
|
||||
const response = await fetch("/api/" + path, {
|
||||
method: method,
|
||||
mode: "cors",
|
||||
|
|
Loading…
Reference in a new issue