1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-30 02:09:37 +02:00

chore: Remove unused imports and variables in settings and signup pages

This commit is contained in:
Sean Morley 2024-05-29 18:01:02 +00:00
parent 41b019b610
commit 3076b78c97
4 changed files with 15 additions and 10 deletions

View file

@ -1,6 +1,5 @@
<script>
import { enhance } from "$app/forms";
import AdventureCard from "$lib/components/AdventureCard.svelte";
export let data;
let username = data.user?.username;

View file

@ -2,9 +2,6 @@
import { page } from "$app/stores";
import { enhance } from "$app/forms";
import { goto } from "$app/navigation";
import { type SubmitFunction } from "@sveltejs/kit";
import type { DatabaseUser } from "lucia";
import UserCard from "$lib/components/UserCard.svelte";
let username: string = "";
@ -13,8 +10,6 @@
let password: string = "";
import ConfirmModal from "$lib/components/ConfirmModal.svelte";
let errors: { addUser?: string } = {};
let sucess: { addUser?: string } = {};
let isModalOpen = false;
async function clearAllSessions() {
@ -35,8 +30,6 @@
isModalOpen = false;
}
let form = $page.form;
let visitCount = $page.data.visitCount[0].count;
let userCount = $page.data.userCount[0].count;
let regionCount = $page.data.regionCount[0].count;

View file

@ -31,6 +31,7 @@ export const actions: Actions = {
const password = formData.get("password");
const firstName = formData.get("first_name");
const lastName = formData.get("last_name");
const confirmPassword = formData.get("passwordConfirm");
// username must be between 4 ~ 31 characters, and only consists of lowercase letters, 0-9, -, and _
// keep in mind some database (e.g. mysql) are case insensitive
@ -38,7 +39,7 @@ export const actions: Actions = {
return redirect(302, "/");
}
// check all to make sure all fields are provided
if (!username || !password || !firstName || !lastName) {
if (!username || !password || !firstName || !lastName || !confirmPassword) {
return error(400, {
message: "All fields are required",
});
@ -84,6 +85,12 @@ export const actions: Actions = {
});
}
if (password !== confirmPassword) {
return error(400, {
message: "Passwords do not match",
});
}
const usernameTaken = await db
.select()
.from(userTable)

View file

@ -39,7 +39,7 @@
class="min-h-screen bg-no-repeat bg-cover flex items-center justify-center"
style="background-image: url('{backgroundImageUrl}')"
>
<div class="card card-compact w-96 bg-base-100 shadow-xl p-6">
<div class="card card-compact w-96 bg-base-100 shadow-xl p-6 mt-4 mb-4">
<article class="text-center text-4xl font-extrabold">
<h1>Signup</h1>
</article>
@ -70,6 +70,12 @@
name="password"
id="password"
class="block mb-2 input input-bordered w-full max-w-xs"
/><br /><label for="password">Confirm Password</label>
<input
type="password"
name="passwordConfirm"
id="passwordConfirm"
class="block mb-2 input input-bordered w-full max-w-xs"
/><br />
<button class="py-2 px-4 btn btn-primary">Signup</button>
</form>