Skip to content

Instantly share code, notes, and snippets.

@kinngh
Created November 24, 2024 15:23
Show Gist options
  • Save kinngh/60de30aae5de35f99d7472b53a2dbd12 to your computer and use it in GitHub Desktop.
Save kinngh/60de30aae5de35f99d7472b53a2dbd12 to your computer and use it in GitHub Desktop.
Enter a Shopify store without manually typing in password
import { useEffect } from "react";
const ShopifyRedirect = () => {
useEffect(() => {
const params = new URLSearchParams(window.location.search);
const store = params.get("store");
const password = params.get("password");
if (!store) {
alert("Store param is missing");
return;
}
if (!password) {
alert("Password param is missing");
return;
}
const form = document.createElement("form");
form.method = "POST";
form.action = `https://${store}/password`;
form.style.display = "none";
const passwordInput = document.createElement("input");
passwordInput.type = "hidden";
passwordInput.name = "password";
passwordInput.value = password;
form.appendChild(passwordInput);
document.body.appendChild(form);
form.submit();
}, []);
return null;
};
export default ShopifyRedirect;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment