partial repository layer added

This commit is contained in:
Fran Jurmanović
2022-09-27 00:33:44 +02:00
parent 13ce0735d0
commit 82e97fc97f
73 changed files with 2686 additions and 1216 deletions

View File

@@ -4,7 +4,7 @@ import (
"errors"
"os"
"strings"
"wallet-api/pkg/models"
"wallet-api/pkg/model"
"wallet-api/pkg/utl/configs"
"github.com/dgrijalva/jwt-go"
@@ -16,11 +16,12 @@ import (
Auth
Checks if token from header is valid and extracts the id.
Args:
*gin.Context: Gin Application Context.
*/
func Auth(c *gin.Context) {
exceptionReturn := new(models.Exception)
exceptionReturn := new(model.Exception)
tokenString := ExtractToken(c)
token, err := CheckToken(tokenString)
if err != nil {
@@ -33,7 +34,7 @@ func Auth(c *gin.Context) {
if ok && token.Valid {
userId, _ := claims["id"].(string)
authModel := new(models.Auth)
authModel := new(model.Auth)
authModel.Id = userId
c.Set("auth", authModel)
@@ -45,6 +46,7 @@ func Auth(c *gin.Context) {
ExtractToken
Extracts token from header
Args:
*gin.Context: Gin Application Context.
Returns:
@@ -66,6 +68,7 @@ func ExtractToken(c *gin.Context) string {
CheckToken
Checks if token is valid
Args:
string: Token to check
Returns:

View File

@@ -3,7 +3,7 @@ package middleware
import (
"net/http"
"os"
"wallet-api/pkg/models"
"wallet-api/pkg/model"
"wallet-api/pkg/utl/configs"
"github.com/gin-gonic/gin"
@@ -13,11 +13,12 @@ import (
SecretCode
Checks if secret code from body is valid.
Args:
*gin.Context: Gin Application Context.
Args:
*gin.Context: Gin Application Context.
*/
func SecretCode(c *gin.Context) {
exceptionReturn := new(models.Exception)
exceptionReturn := new(model.Exception)
secretCode := ExtractCode(c)
secret := os.Getenv("SECRET_CODE")
if secret == "" {
@@ -37,8 +38,9 @@ func SecretCode(c *gin.Context) {
ExtractCode
Extracts the secret code from body.
Args:
*gin.Context: Gin Application Context.
Args:
*gin.Context: Gin Application Context.
*/
func ExtractCode(c *gin.Context) SecretCodeModel {
secret := new(SecretCodeModel)