Auth middleware with JWT
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package responses
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -19,3 +21,11 @@ func Error(c *gin.Context, err string, code int) {
|
||||
"error": err,
|
||||
})
|
||||
}
|
||||
|
||||
func NeedsToLogin(c *gin.Context) {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"success": false,
|
||||
"error": "Authentication required",
|
||||
"needsAuthentication": true, // only appears in this error
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user