frontend: real world movement
This commit is contained in:
@@ -5,7 +5,9 @@ import { fail, redirect } from "@sveltejs/kit";
|
||||
/** @type {import('./$types').PageServerLoad} */
|
||||
export async function load({ locals }) {
|
||||
// redirect user if logged in
|
||||
console.log("loading login page");
|
||||
if (locals.user) {
|
||||
console.log("user is logged in");
|
||||
throw redirect(302, "/");
|
||||
}
|
||||
}
|
||||
@@ -20,11 +22,11 @@ export const actions = {
|
||||
* @returns Error data or redirects user to the home page or the previous page
|
||||
*/
|
||||
login: async ({ request, fetch, cookies }) => {
|
||||
console.log("login action called");
|
||||
const data = await request.formData();
|
||||
const email = String(data.get("email"));
|
||||
const password = String(data.get("password"));
|
||||
const next = String(data.get("next"));
|
||||
|
||||
/** @type {RequestInit} */
|
||||
const requestInitOptions = {
|
||||
method: "POST",
|
||||
@@ -37,9 +39,7 @@ export const actions = {
|
||||
password: password,
|
||||
}),
|
||||
};
|
||||
|
||||
const res = await fetch(`${BASE_API_URI}/users/login/`, requestInitOptions);
|
||||
|
||||
const res = await fetch(`${BASE_API_URI}/users/login`, requestInitOptions);
|
||||
console.log("Login response status:", res.status);
|
||||
console.log("Login response headers:", Object.fromEntries(res.headers));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user