mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
secret code from body instead header
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"wallet-api/pkg/models"
|
"wallet-api/pkg/models"
|
||||||
"wallet-api/pkg/utl/configs"
|
"wallet-api/pkg/utl/configs"
|
||||||
@@ -15,7 +16,6 @@ func SecretCode(c *gin.Context) {
|
|||||||
if secret == "" {
|
if secret == "" {
|
||||||
secret = configs.SecretCode
|
secret = configs.SecretCode
|
||||||
}
|
}
|
||||||
print(secret, secretCode)
|
|
||||||
if secret != secretCode {
|
if secret != secretCode {
|
||||||
exceptionReturn.ErrorCode = "401101"
|
exceptionReturn.ErrorCode = "401101"
|
||||||
exceptionReturn.StatusCode = 401
|
exceptionReturn.StatusCode = 401
|
||||||
@@ -26,6 +26,14 @@ func SecretCode(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExtractCode(c *gin.Context) string {
|
func ExtractCode(c *gin.Context) string {
|
||||||
secret := c.GetHeader("SECRET_CODE")
|
secret := new(SecretCodeModel)
|
||||||
return secret
|
if err := c.ShouldBindJSON(&secret); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return secret.SecretCode
|
||||||
|
}
|
||||||
|
|
||||||
|
type SecretCodeModel struct {
|
||||||
|
SecretCode string `json:"secretCode"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user