mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
9abb227250
Conflicts: - `README.md`: Our README.md files are completely different. Discarded upstream changes. - `app/javascript/core/admin.js`: Updating rails-ujs, no real conflict, but a comment to close to changed code. Various glitch-soc-only files have been updated to match those changes, though. - `package.json`: No real conflict, just an additional dependency in glitch-soc that was too close to something updated upstream. Took upstream's changes.
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
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();
|
|
};
|