User authentication complete

This commit is contained in:
Leons Aleksandrovs
2025-07-06 21:40:32 +03:00
parent d18f9f9706
commit 4e730bfe12
6 changed files with 104 additions and 22 deletions
+2 -2
View File
@@ -16,14 +16,14 @@ func Success(c *gin.Context, data gin.H) {
func Error(c *gin.Context, err string, code int) {
// Return error to api
c.JSON(code, gin.H{
c.AbortWithStatusJSON(code, gin.H{
"success": false,
"error": err,
})
}
func NeedsToLogin(c *gin.Context) {
c.JSON(http.StatusUnauthorized, gin.H{
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
"success": false,
"error": "Authentication required",
"needsAuthentication": true, // only appears in this error