add: api key middleware
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"GoMembership/internal/config"
|
||||
"GoMembership/internal/models"
|
||||
"GoMembership/internal/services"
|
||||
|
||||
@@ -28,19 +27,6 @@ func (mc *MembershipController) RegisterSubscription(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Couldn't decode subscription data"})
|
||||
}
|
||||
|
||||
logger.Info.Printf("Using API key: %v", config.Auth.APIKEY)
|
||||
if regData.APIKey == "" {
|
||||
logger.Error.Println("API Key is missing")
|
||||
c.JSON(http.StatusUnauthorized, "API Key is missing")
|
||||
return
|
||||
}
|
||||
|
||||
if regData.APIKey != config.Auth.APIKEY {
|
||||
logger.Error.Printf("API Key not valid: %v", regData.APIKey)
|
||||
c.JSON(http.StatusUnauthorized, "API Key is missing")
|
||||
return
|
||||
}
|
||||
|
||||
// Register Subscription
|
||||
id, err := mc.Service.RegisterSubscription(®Data.Model)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user