This commit implements a full-stack authentication system using JWT. On the backend, a new login endpoint `/api/token` is created. It validates credentials and issues a signed JWT. A JWT middleware is added to the server configuration to protect sensitive API endpoints like `/api/category` and `/api/operation`. Configuration is now managed via a `wallet.conf` file, loaded at startup. On the frontend, this enables a complete authentication lifecycle: - A new `/login` page allows users to enter their credentials. - A `PrivateRoute` component wraps protected pages, redirecting unauthenticated users to the login page. - API calls to protected resources now include the `Authorization: Bearer <token>` header. - A logout function is added to clear user session data. refactor(ui): enhance history and category views This commit also introduces major UI improvements. The History modal has been completely redesigned. Operations are no longer displayed as a flat list but are now grouped into tabs for Daily, Weekly, Monthly, and Yearly views, providing a much clearer overview of transactions. The Categories modal now separates categories into "Incomes" and "Expenses" tabs, reflecting the changes in the backend data model.
35 lines
512 B
Go
35 lines
512 B
Go
package main
|
|
|
|
import (
|
|
"backend/server"
|
|
"log"
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func main() {
|
|
app := fiber.New()
|
|
|
|
server.Configure(app)
|
|
|
|
enableTls, err := strconv.ParseBool(os.Getenv("ENABLE_TLS"))
|
|
if err != nil {
|
|
log.Fatalf("error read tls configuration, %v", err)
|
|
}
|
|
if enableTls {
|
|
log.Fatal(
|
|
app.ListenTLS(
|
|
os.Getenv("HTTP_ADDRESS"),
|
|
os.Getenv("CERT_FILE"),
|
|
os.Getenv("KEY_FILE"),
|
|
),
|
|
)
|
|
} else {
|
|
log.Fatal(
|
|
app.Listen(os.Getenv("HTTP_ADDRESS")),
|
|
)
|
|
}
|
|
}
|