53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
import { r as redirect } from './index-wpIsICWW.js';
|
|
|
|
const load = async ({ url, locals }) => {
|
|
if (locals.user) {
|
|
throw redirect(303, url.searchParams.get("redirectTo") ?? "/");
|
|
}
|
|
return {
|
|
redirectTo: url.searchParams.get("redirectTo") ?? "",
|
|
error: null
|
|
};
|
|
};
|
|
const actions = {
|
|
default: async ({ request, locals, url }) => {
|
|
const formData = await request.formData();
|
|
const email = String(formData.get("email") ?? "").trim();
|
|
const password = String(formData.get("password") ?? "");
|
|
const redirectTo = String(formData.get("redirectTo") ?? "").trim() || "/";
|
|
if (!email || !password) {
|
|
return {
|
|
redirectTo,
|
|
error: "Email and password are required."
|
|
};
|
|
}
|
|
try {
|
|
await locals.pb.collection("users").authWithPassword(email, password);
|
|
} catch (err) {
|
|
const message = err && typeof err === "object" && "message" in err ? String(err.message) : "Invalid email or password.";
|
|
return {
|
|
redirectTo,
|
|
error: message
|
|
};
|
|
}
|
|
throw redirect(303, redirectTo);
|
|
}
|
|
};
|
|
|
|
var _page_server_ts = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
actions: actions,
|
|
load: load
|
|
});
|
|
|
|
const index = 4;
|
|
let component_cache;
|
|
const component = async () => component_cache ??= (await import('./_page.svelte-CYuAo59m.js')).default;
|
|
const server_id = "src/routes/login/+page.server.ts";
|
|
const imports = ["_app/immutable/nodes/4.BG9kRLiv.js","_app/immutable/chunks/Bzak7iHL.js","_app/immutable/chunks/nEbfNkJh.js","_app/immutable/chunks/CPmvlhtF.js","_app/immutable/chunks/zcqfpVBB.js","_app/immutable/chunks/BpNSSBPP.js","_app/immutable/chunks/CoAkxMBS.js","_app/immutable/chunks/BX9MO-1l.js","_app/immutable/chunks/Xjya7ye4.js","_app/immutable/chunks/uf3Is7Es.js","_app/immutable/chunks/DTd9pe6t.js","_app/immutable/chunks/CvA4ASMA.js"];
|
|
const stylesheets = [];
|
|
const fonts = [];
|
|
|
|
export { component, fonts, imports, index, _page_server_ts as server, server_id, stylesheets };
|
|
//# sourceMappingURL=4-ano5Glp5.js.map
|