feat: adjust routes and make use of middlewares in each one

This commit is contained in:
2025-05-30 21:24:48 +02:00
parent 45e31b41ca
commit 013f300513
2 changed files with 27 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package auth
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
"time"
@ -31,7 +32,7 @@ func (h *AuthHandler) signTokens(user *repository.User) (string, string, error)
Issuer: h.cfg.Jwt.Issuer,
Subject: user.ID.String(),
IssuedAt: jwt.NewNumericDate(time.Now()),
ExpiresAt: jwt.NewNumericDate(time.Now().Add(15 * time.Minute)),
ExpiresAt: jwt.NewNumericDate(time.Now().Add(15 * time.Second)),
},
}
@ -193,6 +194,8 @@ func (h *AuthHandler) login(w http.ResponseWriter, r *http.Request) {
return
}
log.Printf("DEBUG: looking for user with following params: %#v\n", params)
user, err := h.repo.FindUserEmail(r.Context(), params.Email)
if err != nil {
web.Error(w, "user with provided email does not exists", http.StatusBadRequest)