Added sessions to the backend, a basic form of it at least

This commit is contained in:
2024-05-20 17:35:16 +01:00
parent 2179040833
commit 8a625b5fa8
3 changed files with 11 additions and 8 deletions
+6 -4
View File
@@ -8,8 +8,7 @@ import (
"io"
"log"
"net/http"
"thermalFax/views"
"thermalFax/models"
)
type PrintServerResponse struct {
@@ -58,11 +57,14 @@ func sendRequestToPrinter(msg string) (PrintServerResponse, error) {
// sendFax is a function that receives the data from the fronted and
// sends it to the print server
func SendFax(w http.ResponseWriter, r *http.Request) {
if !isAuthenticated(r) {
views.LoginPage(w, r)
authd, token := isAuthenticated(r)
if !authd {
return
}
session, _ := models.GetSession(token)
log.Printf(" | User %s request a fax.", session.User)
data, _ := io.ReadAll(r.Body)
log.Printf("| Received Request: %s", data)