package liman
import (
"github.com/gofiber/fiber/v2"
"github.com/limanmys/render-engine/app/models"
"github.com/limanmys/render-engine/internal/database"
"github.com/limanmys/render-engine/pkg/logger"
)
func AuthWithToken (token string ) (string , error ) {
tokenObj := &models .Token {}
err := database .Connection ().First (&tokenObj , "token = ?" , token ).Error
if err != nil || len (tokenObj .UserID ) < 1 {
return "" , logger .FiberError (fiber .StatusUnauthorized , "authorization token is not valid" )
}
return tokenObj .UserID , nil
}
func AuthWithAccessToken (token string ) (string , error ) {
tokenObj := &models .AccessToken {}
err := database .Connection ().First (&tokenObj , "token = ?" , token ).Error
if err != nil || len (tokenObj .UserID ) < 1 {
return "" , logger .FiberError (fiber .StatusUnauthorized , "authorization token is not valid" )
}
return tokenObj .UserID , nil
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .