kill unexp
This commit is contained in:
parent
5f9ce38917
commit
c66b80e818
|
|
@ -6,3 +6,4 @@ node_modules
|
|||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
dev.sh
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -24,6 +24,8 @@
|
|||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@sveltejs/adapter-node": "^1.0.0-next.96"
|
||||
"@sveltejs/adapter-node": "^1.0.0-next.96",
|
||||
"bcrypt": "^5.1.0",
|
||||
"mongodb": "^4.10.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
<div class="container flex bg-indigo-600 outline outline-1 outline-indigo-700 items-center justify-center mb-2 mt-[-0.5rem]">
|
||||
<div class="container flex bg-blue-600 outline outline-1 outline-blue-700 items-center justify-center mb-2 mt-[-0.5rem]">
|
||||
<p class="text-white">This is an example alert</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
import { MongoClient } from "mongodb";
|
||||
import { hash, compare } from "bcrypt";
|
||||
import { prerendering } from "$app/env";
|
||||
|
||||
if (!process.env.MONGO_URL) throw new Error("Missing MONGO_URL env variable!");
|
||||
|
||||
const client = new MongoClient(process.env.MONGO_URL);
|
||||
if (!prerendering) await client.connect();
|
||||
|
||||
const db = await client.db("rowblox");
|
||||
const users = await db.collection("users");
|
||||
const games = await db.collection("games");
|
||||
const assets = await db.collection("assets");
|
||||
const invites = await db.collection("invites");
|
||||
const avatars = await db.collection("avatars");
|
||||
|
||||
async function inc(collection) {
|
||||
await collection.updateOne({ _id: "_inc" }, { $inc: { _inc: 1 } });
|
||||
return (await collection.findOne({ _id: "_inc" }))._inc;
|
||||
}
|
||||
|
||||
async function hashPassword(plaintext) {
|
||||
return new Promise((resolve, reject) => {
|
||||
hash(plaintext, 10, (err, hash) => resolve(hash));
|
||||
});
|
||||
}
|
||||
|
||||
async function compareHash(plaintext, hash) {
|
||||
return new Promise((resolve, reject) => {
|
||||
compare(plaintext, hash, (err, result) => resolve(result));
|
||||
});
|
||||
}
|
||||
|
||||
export async function createUser(username, password, lastip) {
|
||||
const _id = await inc(users);
|
||||
|
||||
const user = {
|
||||
_id,
|
||||
username,
|
||||
password: await hashPassword(password),
|
||||
lastip
|
||||
};
|
||||
|
||||
const avatar = {
|
||||
_id,
|
||||
BodyColors: {
|
||||
HeadColor: 1,
|
||||
TorsoColor: 1,
|
||||
LeftArmColor: 1,
|
||||
RightArmColor: 1,
|
||||
LeftLegColor: 1,
|
||||
RightLegColor: 1
|
||||
},
|
||||
Assets: {}
|
||||
};
|
||||
|
||||
return await users.insertOne(user);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="navbar bg-blue-900 text-base py-0.5 text-white">
|
||||
<div class="navbar bg-gray-800 text-base py-0.5 text-white">
|
||||
<div class="container flex items-center">
|
||||
<a class="mr-6" href="/my/avatar">Avatar</a>
|
||||
<a class="mr-6" href="/my/friends">Friends</a>
|
||||
|
|
@ -59,15 +59,17 @@
|
|||
<slot />
|
||||
</div>
|
||||
|
||||
<div class="flex text-white py-2 items-center justify-start scrolling-background mt-4">
|
||||
<div class="flex text-white items-center justify-start bg-blue-700 mt-4">
|
||||
<div class="container">
|
||||
<div>
|
||||
<a href="/#">Terms of Service</a>
|
||||
<a href="/#">Rules</a>
|
||||
<a href="/#">Privacy Policy</a>
|
||||
<a href="/#">Credits</a>
|
||||
<a href="/#">Statistics</a>
|
||||
<div class="flex text-center py-2 border-b border-blue-400">
|
||||
<a class="text-lg flex-auto" href="/#">Terms of Service</a>
|
||||
<a class="text-lg flex-auto" href="/#">Rules</a>
|
||||
<a class="text-lg flex-auto" href="/#">Privacy Policy</a>
|
||||
<a class="text-lg flex-auto" href="/#">Credits</a>
|
||||
<a class="text-lg flex-auto" href="/#">Statistics</a>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<img class="w-72 mr-6" src="/img/banner.png" alt="" />
|
||||
</div>
|
||||
<img class="w-60 mr-6" src="/img/banner.png" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue