initial commit with imported utils from old github project

This commit is contained in:
pascalyazid committed 2026-05-10 16:30:28 +02:00
commit 66bb463e23
39 files changed
+1944

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
"use server";
import { generateKeyPair } from "@/utils/security/encrypt_private_key";
import { createClient } from "@/utils/supabase/server";
export async function validateIdentity(plain_pw: string) {
const supabase = createClient();
const user_id = (await (await supabase).auth.getUser()).data.user?.id;
if (user_id == null) {
return null;
}
const { data, error } = await (await supabase)
.from("users")
.select("has_identity")
.eq("id", user_id)
.single();
if (error) {
return null;
}
if (!data.has_identity) {
generateKeyPair(plain_pw, user_id);
const { error } = await (await supabase)
.from("users")
.update({ has_identity: true })
.eq("id", user_id)
.single();
if (error) {
throw error;
}
}
}