mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Generate and save nostr keypair for email users on first signin
This commit is contained in:
parent
a0560c420b
commit
fda7d50b81
@ -85,7 +85,7 @@ const UserProfile = () => {
|
|||||||
<div className="relative flex w-full items-center justify-center">
|
<div className="relative flex w-full items-center justify-center">
|
||||||
<Image
|
<Image
|
||||||
alt="user's avatar"
|
alt="user's avatar"
|
||||||
src={returnImageProxy(user.avatar, user.pubkey)}
|
src={returnImageProxy(user.avatar, user?.pubkey || "")}
|
||||||
width={100}
|
width={100}
|
||||||
height={100}
|
height={100}
|
||||||
className="rounded-full my-4"
|
className="rounded-full my-4"
|
||||||
@ -108,10 +108,12 @@ const UserProfile = () => {
|
|||||||
<h1 className="text-center text-2xl my-2">
|
<h1 className="text-center text-2xl my-2">
|
||||||
{user.username || user?.email || "Anon"}
|
{user.username || user?.email || "Anon"}
|
||||||
</h1>
|
</h1>
|
||||||
<h2 className="text-center text-xl my-2 truncate max-tab:px-4 max-mob:px-4">
|
{user.pubkey && (
|
||||||
<Tooltip target=".pubkey-tooltip" content={"this is your nostr npub"} />
|
<h2 className="text-center text-xl my-2 truncate max-tab:px-4 max-mob:px-4">
|
||||||
{nip19.npubEncode(user.pubkey)} <i className="pi pi-question-circle text-xl pubkey-tooltip" />
|
<Tooltip target=".pubkey-tooltip" content={"this is your nostr npub"} />
|
||||||
</h2>
|
{nip19.npubEncode(user.pubkey)} <i className="pi pi-question-circle text-xl pubkey-tooltip" />
|
||||||
|
</h2>
|
||||||
|
)}
|
||||||
{user?.lightningAddress && (
|
{user?.lightningAddress && (
|
||||||
<h3 className="w-fit mx-auto text-center text-xl my-2 bg-gray-800 rounded-lg p-4">
|
<h3 className="w-fit mx-auto text-center text-xl my-2 bg-gray-800 rounded-lg p-4">
|
||||||
<span className="font-bold">Lightning Address:</span> {user.lightningAddress.name}@plebdevs.com <i className="pi pi-copy cursor-pointer hover:text-gray-400" onClick={() => copyToClipboard(user.lightningAddress.name + "@plebdevs.com")} />
|
<span className="font-bold">Lightning Address:</span> {user.lightningAddress.name}@plebdevs.com <i className="pi pi-copy cursor-pointer hover:text-gray-400" onClick={() => copyToClipboard(user.lightningAddress.name + "@plebdevs.com")} />
|
||||||
|
@ -192,7 +192,7 @@ const UserSettings = () => {
|
|||||||
<div className="relative flex w-full items-center justify-center">
|
<div className="relative flex w-full items-center justify-center">
|
||||||
<Image
|
<Image
|
||||||
alt="user's avatar"
|
alt="user's avatar"
|
||||||
src={returnImageProxy(user.avatar, user.pubkey)}
|
src={returnImageProxy(user.avatar, user?.pubkey || "")}
|
||||||
width={100}
|
width={100}
|
||||||
height={100}
|
height={100}
|
||||||
className="rounded-full my-4"
|
className="rounded-full my-4"
|
||||||
@ -214,10 +214,12 @@ const UserSettings = () => {
|
|||||||
<h1 className="text-center text-2xl my-2">
|
<h1 className="text-center text-2xl my-2">
|
||||||
{user.username || user?.email || "Anon"}
|
{user.username || user?.email || "Anon"}
|
||||||
</h1>
|
</h1>
|
||||||
<h2 className="text-center text-xl my-2 truncate max-tab:px-4 max-mob:px-4">
|
{user.pubkey && (
|
||||||
<Tooltip target=".pubkey-tooltip" content={"this is your nostr npub"} />
|
<h2 className="text-center text-xl my-2 truncate max-tab:px-4 max-mob:px-4">
|
||||||
|
<Tooltip target=".pubkey-tooltip" content={"this is your nostr npub"} />
|
||||||
{nip19.npubEncode(user.pubkey)} <i className="pi pi-question-circle text-xl pubkey-tooltip" />
|
{nip19.npubEncode(user.pubkey)} <i className="pi pi-question-circle text-xl pubkey-tooltip" />
|
||||||
</h2>
|
</h2>
|
||||||
|
)}
|
||||||
{user?.lightningAddress && (
|
{user?.lightningAddress && (
|
||||||
<h3 className="w-fit mx-auto text-center text-xl my-2 bg-gray-800 rounded-lg p-4">
|
<h3 className="w-fit mx-auto text-center text-xl my-2 bg-gray-800 rounded-lg p-4">
|
||||||
<span className="font-bold">Lightning Address:</span> {user.lightningAddress.name}@plebdevs.com <i className="pi pi-copy cursor-pointer hover:text-gray-400" onClick={() => copyToClipboard(user.lightningAddress.name + "@plebdevs.com")} />
|
<span className="font-bold">Lightning Address:</span> {user.lightningAddress.name}@plebdevs.com <i className="pi pi-copy cursor-pointer hover:text-gray-400" onClick={() => copyToClipboard(user.lightningAddress.name + "@plebdevs.com")} />
|
||||||
|
@ -169,6 +169,23 @@ export const authOptions = {
|
|||||||
token.user = newUser;
|
token.user = newUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we sign up with email and we don't have a pubkey or privkey, we need to generate them
|
||||||
|
if (trigger === "signUp" && account?.provider === "email" && !user.pubkey && !user.privkey) {
|
||||||
|
const sk = generateSecretKey();
|
||||||
|
const pubkey = getPublicKey(sk);
|
||||||
|
const privkey = bytesToHex(sk);
|
||||||
|
|
||||||
|
// Update the user in the database
|
||||||
|
await prisma.user.update({
|
||||||
|
where: { id: user.id },
|
||||||
|
data: { pubkey, privkey }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update the user object
|
||||||
|
user.pubkey = pubkey;
|
||||||
|
user.privkey = privkey;
|
||||||
|
}
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
token.user = user;
|
token.user = user;
|
||||||
if (user.pubkey && user.privkey) {
|
if (user.pubkey && user.privkey) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user