Add template table to the database Create controller function to check if user has template, and create it in the database Made universal jwt.Claims of user data retrieval function
32 lines
602 B
Go
32 lines
602 B
Go
package responses
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func Success(c *gin.Context, data any) {
|
|
// Return success to api
|
|
c.JSON(200, gin.H{
|
|
"success": true,
|
|
"data": data,
|
|
})
|
|
}
|
|
|
|
func Error(c *gin.Context, err string, code int) {
|
|
// Return error to api
|
|
c.AbortWithStatusJSON(code, gin.H{
|
|
"success": false,
|
|
"error": err,
|
|
})
|
|
}
|
|
|
|
func NeedsToLogin(c *gin.Context) {
|
|
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
|
|
"success": false,
|
|
"error": "Authentication required",
|
|
"needsAuthentication": true, // only appears in this error
|
|
})
|
|
}
|