forked from PolarisPyra/daphnis
48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
"use server";
|
|
|
|
import { getAuth } from "@/auth/queries/getauth";
|
|
import { artemis, daphnis } from "@/lib/prisma";
|
|
|
|
export const getUsername = async () => {
|
|
const { user } = await getAuth();
|
|
if (user) {
|
|
return await daphnis.user.findFirst({
|
|
where: {
|
|
id: user.id,
|
|
username: user.username,
|
|
},
|
|
});
|
|
}
|
|
return null;
|
|
};
|
|
|
|
export async function getAllAimeCards() {
|
|
const { user } = await getAuth();
|
|
|
|
if (!user || !user.accessCode) {
|
|
throw new Error("User is not authenticated or accessCode is missing");
|
|
}
|
|
|
|
const aimeUser = await daphnis.user.findMany({
|
|
where: {
|
|
accessCode: user.accessCode,
|
|
},
|
|
});
|
|
return aimeUser;
|
|
}
|
|
|
|
export async function verifyAimeCodeAgainstArtemis() {
|
|
const { user } = await getAuth();
|
|
|
|
if (!user || !user.accessCode) {
|
|
throw new Error("User is not authenticated or accessCode is missing");
|
|
}
|
|
|
|
const aimeUser = await artemis.aime_card.findFirst({
|
|
where: {
|
|
access_code: user.accessCode,
|
|
},
|
|
});
|
|
return aimeUser;
|
|
}
|