Changed leftovers to daphnis

This commit is contained in:
polaris 2024-06-29 01:46:07 -04:00
parent 14456e5397
commit 9950e50bfd
7 changed files with 24 additions and 18 deletions

6
.gitignore vendored
View File

@ -23,4 +23,8 @@ logs
.node_repl_history .node_repl_history
# Environment variables # Environment variables
.env* .env*
#nextjs
.next

View File

@ -1,6 +1,6 @@
"use server"; "use server";
import { lachesis } from "@/lib/prisma"; import { daphnis } from "@/lib/prisma";
import { randomUUID } from "crypto"; import { randomUUID } from "crypto";
import { Resend } from "resend"; import { Resend } from "resend";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
@ -39,7 +39,7 @@ export async function EmailPasswordResetLink(data: FormData) {
}; };
} }
const user = await lachesis.user.findUnique({ const user = await daphnis.user.findUnique({
where: { email }, where: { email },
}); });
@ -49,7 +49,7 @@ export async function EmailPasswordResetLink(data: FormData) {
}; };
} }
const token = await lachesis.passwordResetToken.create({ const token = await daphnis.passwordResetToken.create({
data: { data: {
id: randomUUID(), id: randomUUID(),
userId: user.id, userId: user.id,

View File

@ -1,7 +1,7 @@
"use server"; "use server";
import { getAuth } from "@/auth/queries/getauth"; import { getAuth } from "@/auth/queries/getauth";
import { lachesis } from "@/lib/prisma"; import { daphnis } from "@/lib/prisma";
import { randomUUID } from "crypto"; import { randomUUID } from "crypto";
import { randomBytes } from "crypto"; import { randomBytes } from "crypto";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
@ -20,7 +20,7 @@ export async function generateShareToken(id: number): Promise<{
} }
const gernatetoken = randomBytes(5).readUInt32BE(0).toString(); const gernatetoken = randomBytes(5).readUInt32BE(0).toString();
const token = await lachesis.linkSharingToken.create({ const token = await daphnis.linkSharingToken.create({
data: { data: {
playlogId: id, playlogId: id,
id: randomUUID(), id: randomUUID(),
@ -34,7 +34,7 @@ export async function generateShareToken(id: number): Promise<{
} }
export async function shareScore(token: string) { export async function shareScore(token: string) {
const PublicPage = await lachesis.linkSharingToken.findUnique({ const PublicPage = await daphnis.linkSharingToken.findUnique({
where: { where: {
token, token,
}, },
@ -52,7 +52,7 @@ export async function shareScore(token: string) {
const tokenAgeLimit = 1000 * 60 * 60 * 24; // 1 day in milliseconds const tokenAgeLimit = 1000 * 60 * 60 * 24; // 1 day in milliseconds
if (tokenAge > tokenAgeLimit) { if (tokenAge > tokenAgeLimit) {
await lachesis.linkSharingToken.update({ await daphnis.linkSharingToken.update({
where: { where: {
token, token,
}, },

View File

@ -4,7 +4,7 @@ import { cookies } from "next/headers";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import { Argon2id } from "oslo/password"; import { Argon2id } from "oslo/password";
import { lucia } from "@/lib/lucia"; import { lucia } from "@/lib/lucia";
import { lachesis } from "@/lib/prisma"; import { daphnis } from "@/lib/prisma";
const signIn = async (formData: FormData) => { const signIn = async (formData: FormData) => {
const formDataRaw = { const formDataRaw = {
@ -13,7 +13,7 @@ const signIn = async (formData: FormData) => {
}; };
try { try {
const user = await lachesis.user.findUnique({ const user = await daphnis.user.findUnique({
where: { username: formDataRaw.username }, where: { username: formDataRaw.username },
}); });

View File

@ -5,7 +5,7 @@ import { cookies } from "next/headers";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import { Argon2id } from "oslo/password"; import { Argon2id } from "oslo/password";
import { lucia } from "@/lib/lucia"; import { lucia } from "@/lib/lucia";
import { lachesis, artemis } from "@/lib/prisma"; import { daphnis, artemis } from "@/lib/prisma";
const signUp = async (formData: FormData) => { const signUp = async (formData: FormData) => {
const formDataRaw = { const formDataRaw = {
@ -22,7 +22,7 @@ const signUp = async (formData: FormData) => {
try { try {
// Check if access code is already used in lachesis database // Check if access code is already used in lachesis database
const existingUser = await lachesis.user.findFirst({ const existingUser = await daphnis.user.findFirst({
where: { where: {
accessCode: formDataRaw.accessCode, accessCode: formDataRaw.accessCode,
}, },
@ -33,7 +33,7 @@ const signUp = async (formData: FormData) => {
} }
// Check if username is already used in lachesis database // Check if username is already used in lachesis database
const existingUsername = await lachesis.user.findFirst({ const existingUsername = await daphnis.user.findFirst({
where: { where: {
username: formDataRaw.username, username: formDataRaw.username,
}, },
@ -43,7 +43,7 @@ const signUp = async (formData: FormData) => {
return { error: "Username is currently taken" }; return { error: "Username is currently taken" };
} }
const existingEmail = await lachesis.user.findFirst({ const existingEmail = await daphnis.user.findFirst({
where: { where: {
email: formDataRaw.email, email: formDataRaw.email,
}, },
@ -68,7 +68,7 @@ const signUp = async (formData: FormData) => {
const userId = generateId(15); const userId = generateId(15);
// Create user in the lachesis database // Create user in the lachesis database
await lachesis.user.create({ await daphnis.user.create({
data: { data: {
id: userId, id: userId,
username: formDataRaw.username, username: formDataRaw.username,
@ -90,10 +90,12 @@ const signUp = async (formData: FormData) => {
console.log("Account created"); console.log("Account created");
// Redirect to home page // Redirect to home page
redirect("/home");
} catch (error: any) { } catch (error: any) {
return { error: "Account creation failed: " + error.message }; return { error: "Account creation failed: " + error.message };
} }
redirect("/home");
}; };
export { signUp }; export { signUp };

View File

@ -5,7 +5,7 @@ import { artemis } from "@/lib/prisma";
import { daphnis } from "@/lib/prisma"; import { daphnis } from "@/lib/prisma";
export async function getSongsWithTitles(userId: number) { export async function getSongsWithTitles(userId: number) {
try { try {
// Fetch songs from ChuniScorePlaylog
const songs = await artemis.chuni_score_playlog.findMany({ const songs = await artemis.chuni_score_playlog.findMany({
where: { where: {
user: userId, user: userId,

View File

@ -7,7 +7,7 @@
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "bundler", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",