Created
November 24, 2024 15:23
-
-
Save kinngh/60de30aae5de35f99d7472b53a2dbd12 to your computer and use it in GitHub Desktop.
Enter a Shopify store without manually typing in password
This file contains hidden or 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
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