This commit is contained in:
2025-12-15 12:28:00 -06:00
parent bdc709ec2a
commit cf1ffac9ee
14 changed files with 3181 additions and 1 deletions
+41
View File
@@ -0,0 +1,41 @@
// Authentication functions
/**
* Login with email and password
*/
async function login(email, password) {
try {
const authData = await pb.collection('users').authWithPassword(email, password);
return authData;
} catch (error) {
console.error('Login error:', error);
throw new Error(error.message || 'Login failed. Please check your credentials.');
}
}
/**
* Logout current user
*/
function logout() {
pb.authStore.clear();
window.location.href = 'index.html';
}
/**
* Check if user is authenticated, redirect to login if not
*/
function checkAuth() {
if (!pb.authStore.isValid) {
window.location.href = 'index.html';
return false;
}
return true;
}
/**
* Get current user
*/
function getCurrentUser() {
return pb.authStore.model;
}