better passphrase auth
This commit is contained in:
parent
9185213a50
commit
3c192feb3b
@ -18,6 +18,7 @@ export default function LoginModal() {
|
|||||||
const { loginWithPubkey, currentUser } = useCurrentUser();
|
const { loginWithPubkey, currentUser } = useCurrentUser();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [showExtensionLogin, setShowExtensionLogin] = useState(true);
|
const [showExtensionLogin, setShowExtensionLogin] = useState(true);
|
||||||
|
const [showPassphraseLogin, setShowPassphraseLogin] = useState(false);
|
||||||
const [nsec, setNsec] = useState("");
|
const [nsec, setNsec] = useState("");
|
||||||
const [passphrase, setPassphrase] = useState("");
|
const [passphrase, setPassphrase] = useState("");
|
||||||
const [encryptedNsec, setEncryptedNsec] = useState("");
|
const [encryptedNsec, setEncryptedNsec] = useState("");
|
||||||
@ -61,6 +62,7 @@ export default function LoginModal() {
|
|||||||
};
|
};
|
||||||
if (encryptedNsec_) {
|
if (encryptedNsec_) {
|
||||||
setEncryptedNsec(encryptedNsec_);
|
setEncryptedNsec(encryptedNsec_);
|
||||||
|
setShowPassphraseLogin(true);
|
||||||
} else if (shouldReconnect === "true") {
|
} else if (shouldReconnect === "true") {
|
||||||
getConnected(shouldReconnect);
|
getConnected(shouldReconnect);
|
||||||
}
|
}
|
||||||
@ -91,7 +93,7 @@ export default function LoginModal() {
|
|||||||
modal?.hide();
|
modal?.hide();
|
||||||
}
|
}
|
||||||
async function handleLoginPassphrase() {
|
async function handleLoginPassphrase() {
|
||||||
if (!encryptedNsec || passphrase) return;
|
if (!encryptedNsec || !passphrase) return;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
const decryptedNsec = decryptMessage(encryptedNsec, passphrase);
|
const decryptedNsec = decryptMessage(encryptedNsec, passphrase);
|
||||||
@ -136,13 +138,14 @@ export default function LoginModal() {
|
|||||||
Connect with extension
|
Connect with extension
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{!!encryptedNsec && (
|
{showPassphraseLogin ? (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<Label>Passphrase</Label>
|
<Label>Passphrase</Label>
|
||||||
<Input
|
<Input
|
||||||
value={nsec}
|
value={passphrase}
|
||||||
onChange={(e) => setPassphrase(e.target.value)}
|
onChange={(e) => setPassphrase(e.target.value)}
|
||||||
placeholder="passphrase..."
|
placeholder="passphrase..."
|
||||||
|
type="password"
|
||||||
className="text-[16px]"
|
className="text-[16px]"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
@ -153,8 +156,18 @@ export default function LoginModal() {
|
|||||||
>
|
>
|
||||||
Login with Passphrase
|
Login with Passphrase
|
||||||
</Button>
|
</Button>
|
||||||
|
<div className="center">
|
||||||
|
<Button
|
||||||
|
variant={"link"}
|
||||||
|
size={"sm"}
|
||||||
|
className="h-0 pt-1"
|
||||||
|
onClick={() => setShowPassphraseLogin(false)}
|
||||||
|
>
|
||||||
|
Or, use Nsec
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
|
) : (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<Label>Nsec</Label>
|
<Label>Nsec</Label>
|
||||||
<Input
|
<Input
|
||||||
@ -171,7 +184,20 @@ export default function LoginModal() {
|
|||||||
>
|
>
|
||||||
Connect with Nsec
|
Connect with Nsec
|
||||||
</Button>
|
</Button>
|
||||||
|
{!!encryptedNsec && (
|
||||||
|
<div className="center">
|
||||||
|
<Button
|
||||||
|
variant={"link"}
|
||||||
|
size={"sm"}
|
||||||
|
className="h-0 pt-1"
|
||||||
|
onClick={() => setShowPassphraseLogin(true)}
|
||||||
|
>
|
||||||
|
Or, use Passphrase
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Template>
|
</Template>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user