forked from PolarisPyra/daphnis
made it so it gabs the game version from your profile
This commit is contained in:
parent
7226a2c9e0
commit
aef93cc89c
@ -6,6 +6,7 @@ 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 { daphnis, artemis } from "@/lib/prisma";
|
import { daphnis, artemis } from "@/lib/prisma";
|
||||||
|
import { GameVersion } from "@/prisma/schemas/daphnis/generated/daphnis";
|
||||||
|
|
||||||
const signUp = async (formData: FormData) => {
|
const signUp = async (formData: FormData) => {
|
||||||
const formDataRaw = {
|
const formDataRaw = {
|
||||||
@ -60,6 +61,13 @@ const signUp = async (formData: FormData) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const existingAccessCodeAndPlayedGame =
|
||||||
|
await artemis.chuni_profile_data.findFirst({
|
||||||
|
where: {
|
||||||
|
user: existingAccessCode?.user,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (!existingAccessCode) {
|
if (!existingAccessCode) {
|
||||||
return { error: "Not in artemis's database, Nice try ^_^" };
|
return { error: "Not in artemis's database, Nice try ^_^" };
|
||||||
}
|
}
|
||||||
@ -67,8 +75,26 @@ const signUp = async (formData: FormData) => {
|
|||||||
const hashedPassword = await new Argon2id().hash(formDataRaw.password);
|
const hashedPassword = await new Argon2id().hash(formDataRaw.password);
|
||||||
const userId = generateId(15);
|
const userId = generateId(15);
|
||||||
|
|
||||||
const artemisUserId = existingAccessCode.user;
|
const artemisUserId = existingAccessCode.user;
|
||||||
// Create user in the daphnis database
|
|
||||||
|
type GameVersionKey = keyof typeof GameVersion;
|
||||||
|
|
||||||
|
// need to make a record so we can get the game version from the db into daphnis where its stored as a string
|
||||||
|
const NumberToGameVersionKey: Record<number, GameVersionKey> = {
|
||||||
|
16: "LuminousPlus",
|
||||||
|
15: "Luminous",
|
||||||
|
14: "SunPlus",
|
||||||
|
13: "Sun",
|
||||||
|
12: "NewPlus",
|
||||||
|
11: "New",
|
||||||
|
};
|
||||||
|
|
||||||
|
const currentGameVersion = existingAccessCodeAndPlayedGame?.version;
|
||||||
|
const gameVersionKey = NumberToGameVersionKey[currentGameVersion ?? 0];
|
||||||
|
const gameIdToName = gameVersionKey
|
||||||
|
? GameVersion[gameVersionKey]
|
||||||
|
: undefined;
|
||||||
|
|
||||||
await daphnis.user.create({
|
await daphnis.user.create({
|
||||||
data: {
|
data: {
|
||||||
UserId: artemisUserId,
|
UserId: artemisUserId,
|
||||||
@ -76,6 +102,7 @@ const signUp = async (formData: FormData) => {
|
|||||||
username: formDataRaw.username,
|
username: formDataRaw.username,
|
||||||
email: formDataRaw.email,
|
email: formDataRaw.email,
|
||||||
accessCode: formDataRaw.accessCode,
|
accessCode: formDataRaw.accessCode,
|
||||||
|
gameVersion: gameIdToName,
|
||||||
hashedPassword,
|
hashedPassword,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -87,7 +114,7 @@ const signUp = async (formData: FormData) => {
|
|||||||
cookies().set(
|
cookies().set(
|
||||||
sessionCookie.name,
|
sessionCookie.name,
|
||||||
sessionCookie.value,
|
sessionCookie.value,
|
||||||
sessionCookie.attributes
|
sessionCookie.attributes,
|
||||||
);
|
);
|
||||||
console.log("Account created");
|
console.log("Account created");
|
||||||
|
|
||||||
@ -96,7 +123,6 @@ const signUp = async (formData: FormData) => {
|
|||||||
return { error: "Account creation failed: " + error.message };
|
return { error: "Account creation failed: " + error.message };
|
||||||
}
|
}
|
||||||
redirect("/home");
|
redirect("/home");
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { signUp };
|
export { signUp };
|
||||||
|
@ -1022,7 +1022,7 @@ model cozynet_artemisapi_sessions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model cozynet_chuni_static_accessory {
|
model cozynet_chuni_static_accessory {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id
|
||||||
str String? @db.VarChar(255)
|
str String? @db.VarChar(255)
|
||||||
imagePath String? @db.VarChar(255)
|
imagePath String? @db.VarChar(255)
|
||||||
sortName String? @db.VarChar(255)
|
sortName String? @db.VarChar(255)
|
||||||
@ -1032,7 +1032,7 @@ model cozynet_chuni_static_accessory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model cozynet_chuni_static_mapicon {
|
model cozynet_chuni_static_mapicon {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id
|
||||||
str String? @db.VarChar(255)
|
str String? @db.VarChar(255)
|
||||||
imagePath String? @db.VarChar(255)
|
imagePath String? @db.VarChar(255)
|
||||||
sortName String? @db.VarChar(255)
|
sortName String? @db.VarChar(255)
|
||||||
@ -1042,7 +1042,7 @@ model cozynet_chuni_static_mapicon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model cozynet_chuni_static_nameplate {
|
model cozynet_chuni_static_nameplate {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id
|
||||||
str String? @db.VarChar(255)
|
str String? @db.VarChar(255)
|
||||||
imagePath String? @db.VarChar(255)
|
imagePath String? @db.VarChar(255)
|
||||||
sortName String? @db.VarChar(255)
|
sortName String? @db.VarChar(255)
|
||||||
@ -1052,7 +1052,7 @@ model cozynet_chuni_static_nameplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model cozynet_chuni_static_systemvoice {
|
model cozynet_chuni_static_systemvoice {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id
|
||||||
str String? @db.VarChar(255)
|
str String? @db.VarChar(255)
|
||||||
imagePath String? @db.VarChar(255)
|
imagePath String? @db.VarChar(255)
|
||||||
sortName String? @db.VarChar(255)
|
sortName String? @db.VarChar(255)
|
||||||
@ -1062,7 +1062,7 @@ model cozynet_chuni_static_systemvoice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model cozynet_chuni_static_trophies {
|
model cozynet_chuni_static_trophies {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id
|
||||||
str String? @db.VarChar(255)
|
str String? @db.VarChar(255)
|
||||||
imagePath String? @db.VarChar(255)
|
imagePath String? @db.VarChar(255)
|
||||||
sortName String? @db.VarChar(255)
|
sortName String? @db.VarChar(255)
|
||||||
|
@ -34,7 +34,7 @@ model User {
|
|||||||
username String @unique
|
username String @unique
|
||||||
accessCode String @unique
|
accessCode String @unique
|
||||||
UserId Int @unique
|
UserId Int @unique
|
||||||
gameVersion GameVersion @default(Luminous)
|
gameVersion GameVersion
|
||||||
|
|
||||||
hashedPassword String
|
hashedPassword String
|
||||||
email String @unique
|
email String @unique
|
||||||
|
Loading…
Reference in New Issue
Block a user