Started Authentication System

This commit is contained in:
2026-02-22 14:47:17 +01:00
parent c492228e22
commit b5840984b8
7 changed files with 126 additions and 38 deletions

View File

@@ -3,6 +3,7 @@ package handlers
import (
"encoding/json"
"net/http"
"shap-planner-backend/auth"
"shap-planner-backend/models"
"shap-planner-backend/storage"
"shap-planner-backend/utils"
@@ -11,7 +12,7 @@ import (
func Register(w http.ResponseWriter, r *http.Request) {
var user models.User
_ = json.NewDecoder(r.Body).Decode(&user)
hashed, _ := utils.HashPassword(user.Password)
hashed, _ := auth.HashPassword(user.Password)
user.Password = hashed
user.ID = utils.GenerateUUID()
@@ -36,7 +37,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
return
}
if !utils.CheckPasswordHash(creds.Password, user.Password) {
if !auth.CheckPasswordHash(creds.Password, user.Password) {
http.Error(w, "Wrong password", http.StatusUnauthorized)
return
}

7
handlers/expenses.go Normal file
View File

@@ -0,0 +1,7 @@
package handlers
import "net/http"
func GetExpenses(w http.ResponseWriter, r *http.Request) {}
func AdminPanel(w http.ResponseWriter, r *http.Request) {}