Initial commit from saas-meta

This commit is contained in:
Hamza-Ayed
2026-03-30 17:04:27 +03:00
commit 3b28389dc3
91 changed files with 20697 additions and 0 deletions

36
frontend/src/auth.js Normal file
View File

@@ -0,0 +1,36 @@
/**
* Authentication Helper
* هيلبر المصادقة
*/
export const auth = {
// Current User Key in LocalStorage
STORAGE_KEY: 'saas_user',
// Save user info to local storage
login(user) {
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(user));
return user;
},
// Remove user info (Logout)
logout() {
localStorage.removeItem(this.STORAGE_KEY);
window.location.reload();
},
// Get current user info
getUser() {
const user = localStorage.getItem(this.STORAGE_KEY);
return user ? JSON.parse(user) : null;
},
// Check if user is logged in
isAuthenticated() {
return this.getUser() !== null;
},
// Get User ID for API headers
getUserId() {
return this.getUser()?.id || '';
}
};