stack/examples/js-example/password-sign-up-script.ts
Bilal Godil c91a23ee88 Hexclave rename PR5: rename stack*App local-variable convention
Step 5: rename lowercase local vars stackApp/stackServerApp/stackClientApp/
stackAdminApp -> hexclave* across SDK source, apps, examples, and docs-mintlify
(docs/ excluded). Public StackServerApp/StackClientApp classes and the
useStackApp hook are unchanged. typecheck + lint green.
2026-06-03 12:17:14 -07:00

36 lines
1023 B
TypeScript

import { hexclaveClientApp } from "./hexclave";
// Check if user is already signed in
hexclaveClientApp.getUser().then((user) => {
if (user) {
window.location.href = "/";
}
});
document.getElementById("signUp")?.addEventListener("click", async () => {
const emailInput = document.getElementById("signUpEmail") as HTMLInputElement;
const passwordInput = document.getElementById("signUpPassword") as HTMLInputElement;
const result = await hexclaveClientApp.signUpWithCredential({
email: emailInput.value,
password: passwordInput.value,
});
if (result.status === "error") {
alert("Sign up failed. Please try again.");
return;
}
const signInResult = await hexclaveClientApp.signInWithCredential({
email: emailInput.value,
password: passwordInput.value,
});
if (signInResult.status === "error") {
alert("Account created but sign in failed. Please sign in manually.");
window.location.href = "/password-sign-in";
} else {
window.location.href = "/";
}
});