more verbose
This commit is contained in:
parent
3fb4afed4d
commit
a64532a5a0
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
gin "github.com/gin-gonic/gin"
|
gin "github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -50,7 +51,15 @@ func Authorization(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(API_KEYS) != 0 && !API_KEYS[c.Request.Header.Get("Authorization")] {
|
if len(API_KEYS) != 0 && !API_KEYS[c.Request.Header.Get("Authorization")] {
|
||||||
c.JSON(401, gin.H{"error": "Unauthorized"})
|
if c.Request.Header.Get("Authorization") == "" {
|
||||||
|
c.JSON(401, gin.H{"error": "No API key provided. Get one at https://discord.gg/9K2BvbXEHT"})
|
||||||
|
} else if strings.HasPrefix(c.Request.Header.Get("Authorization"), "Bearer sk-") {
|
||||||
|
c.JSON(401, gin.H{"error": "You tried to use the official API key which is not supported."})
|
||||||
|
} else if strings.HasPrefix(c.Request.Header.Get("Authorization"), "Bearer eyJhbGciOiJSUzI1NiI") {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
c.JSON(401, gin.H{"error": "Invalid API key."})
|
||||||
|
}
|
||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user