Verified Commit 9762592e authored by Haelwenn's avatar Haelwenn
Browse files

log_out.js: Fix for WebKit

My guess is that hidden forms are broken or forbidden on it.
This greatly simplifies the code anyway.

Tested in: WebKitGTK 2.28.3, Firefox 78.0.2-1, Chromium 84.0.4147.89-1
Closes: #85
parent e0788087
Pipeline #29097 passed with stage
in 4 minutes and 55 seconds
export const preferencesLink = undefined; // '/settings/preferences';
export const profileLink = undefined; // '/settings/profile';
export const signOutLink = undefined; // '/auth/sign_out';
export const signOutLink = '/auth/sign_out';
export const termsLink = undefined; // '/terms';
export const accountAdminLink = (id) => `/pleroma/admin/#/users/${id}/`;
export const statusAdminLink = (account_id, status_id) => `/pleroma/admin/#/users/${account_id}/`;
......
......@@ -2,33 +2,9 @@ import Rails from '@rails/ujs';
import { signOutLink } from 'flavours/glitch/util/backend_links';
export const logOut = () => {
const form = document.createElement('form');
const methodInput = document.createElement('input');
methodInput.setAttribute('name', '_method');
methodInput.setAttribute('value', 'delete');
methodInput.setAttribute('type', 'hidden');
form.appendChild(methodInput);
const csrfToken = Rails.csrfToken();
const csrfParam = Rails.csrfParam();
if (csrfParam && csrfToken) {
const csrfInput = document.createElement('input');
csrfInput.setAttribute('name', csrfParam);
csrfInput.setAttribute('value', csrfToken);
csrfInput.setAttribute('type', 'hidden');
form.appendChild(csrfInput);
}
const submitButton = document.createElement('input');
submitButton.setAttribute('type', 'submit');
form.appendChild(submitButton);
form.method = 'post';
form.action = signOutLink;
form.style.display = 'none';
document.body.appendChild(form);
submitButton.click();
fetch(signOutLink, {
method: 'DELETE'
}).then(() => {
window.location = '/web/';
});
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment