Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions analytics-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function formatAnalyticsCurrency(value, options = {}) {
// ========================

async function getAuthHeaders() {
const token = localStorage.getItem('authToken');
const token = localStorage.getItem('token');
return {
'Content-Type': 'application/json',
'Authorization': token ? `Bearer ${token}` : ''
Expand All @@ -46,7 +46,7 @@ async function getAuthHeaders() {
*/
async function fetchSpendingTrends(period = 'monthly', months = 6) {
try {
const token = localStorage.getItem('authToken');
const token = localStorage.getItem('token');
if (!token) return { data: [] };

const response = await fetch(
Expand Down Expand Up @@ -671,7 +671,7 @@ async function loadAnalyticsDashboard() {
const dashboardContainer = document.getElementById('analytics-dashboard');
if (!dashboardContainer) return;

const token = localStorage.getItem('authToken');
const token = localStorage.getItem('token');
if (!token) return;

try {
Expand Down
2 changes: 1 addition & 1 deletion api-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const formatAppCurrency = (value, { showPlus = false, absolute = false } = {}) =
// ========================

function getAuthToken() {
return localStorage.getItem('authToken');
return localStorage.getItem('token');
}

async function fetchExpenses(page = 1, limit = 50, workspaceId = null) {
Expand Down
10 changes: 5 additions & 5 deletions auth-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

var API_BASE_URL = '/api';
var authToken = localStorage.getItem('authToken');
var authToken = localStorage.getItem('token');
var currentUser = JSON.parse(localStorage.getItem('currentUser') || 'null');
var currentSessionId = localStorage.getItem('sessionId');

Expand All @@ -30,7 +30,7 @@ async function register(userData) {
currentUser = data.user;
currentSessionId = data.sessionId;

localStorage.setItem('authToken', authToken);
localStorage.setItem('token ', authToken);
localStorage.setItem('currentUser', JSON.stringify(currentUser));
localStorage.setItem('sessionId', currentSessionId);

Expand Down Expand Up @@ -67,7 +67,7 @@ async function login(credentials) {
currentUser = data.user;
currentSessionId = data.sessionId;

localStorage.setItem('authToken', authToken);
localStorage.setItem('token', authToken);
localStorage.setItem('currentUser', JSON.stringify(currentUser));
localStorage.setItem('sessionId', currentSessionId);

Expand Down Expand Up @@ -95,7 +95,7 @@ async function verify2FA(userId, totpToken, rememberMe = false) {
currentUser = data.user;
currentSessionId = data.sessionId;

localStorage.setItem('authToken', authToken);
localStorage.setItem('token', authToken);
localStorage.setItem('currentUser', JSON.stringify(currentUser));
localStorage.setItem('sessionId', currentSessionId);

Expand All @@ -119,7 +119,7 @@ async function logout() {
authToken = null;
currentUser = null;
currentSessionId = null;
localStorage.removeItem('authToken');
localStorage.removeItem('token');
localStorage.removeItem('currentUser');
localStorage.removeItem('sessionId');
localStorage.removeItem('transactions');
Expand Down
4 changes: 2 additions & 2 deletions budget-goals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class BudgetGoalsManager {
constructor() {
this.apiUrl = '/api';
this.authToken = localStorage.getItem('authToken');
this.authToken = localStorage.getItem('token');
this.initializeDashboard();
}

Expand Down Expand Up @@ -199,7 +199,7 @@ class BudgetGoalsManager {

// Load dashboard data
async loadDashboardData() {
this.authToken = localStorage.getItem('authToken');
this.authToken = localStorage.getItem('token');
if (!this.authToken) return;

try {
Expand Down
21 changes: 21 additions & 0 deletions middleware/authMiddleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const jwt=require("jsonwebtoken");


const protect=async(req,res,next)=>{
const authHeader=req.headers.authorization;

if(!authHeader || !authHeader.startsWith("Bearer")){
return res.status(401).json({message:"unauthorzed access"});
}
try{
const token=authHeader.split(" ")[1];
const decoded=jwt.verify(token,process.env,JWT_SECRET);
req.user=decoded;
next();
}
catch(err){
return res.status(401).json({message:"Invalid token"});
}

};
module.exports=protect;
2 changes: 1 addition & 1 deletion notification-center.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class NotificationCenter {
constructor() {
this.apiUrl = 'http://localhost:3000/api';
this.authToken = localStorage.getItem('authToken');
this.authToken = localStorage.getItem('token');
this.notifications = [];
this.unreadCount = 0;
this.socket = null;
Expand Down
79 changes: 78 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"axios": "^1.6.2",
"bcryptjs": "^2.4.3",
"canvas": "^3.2.1",
"chart.js": "^4.4.1",
"chart.js": "^4.5.1",
"chartjs-node-canvas": "^5.0.0",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
Expand All @@ -36,6 +36,7 @@
"qrcode": "^1.5.4",
"simple-statistics": "^7.8.3",
"socket.io": "^4.8.3",
"socket.io-client": "^4.8.3",
"twilio": "^5.12.0",
"web-push": "^3.6.7",
"xero-node": "^13.3.1",
Expand Down
2 changes: 1 addition & 1 deletion public/Community.html
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@
</style>

<div class="cursor-trail-container" id="cursor-trail"></div>

<script src="protect.js"></script>
<script>
(function() {
// Hide default cursor
Expand Down
2 changes: 1 addition & 1 deletion public/Help-Center.html
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
</style>

<div class="cursor-trail-container" id="cursor-trail"></div>

<script src="protect.js"></script>
<script>
(function() {
// Hide default cursor
Expand Down
Loading