Fix broken time check

This commit is contained in:
rxdn 2022-07-22 17:29:04 +01:00
parent d34091e8ae
commit 0afe2f5239

View File

@ -83,13 +83,13 @@ func WhitelabelPost(ctx *gin.Context) {
}
func validateToken(token string) bool {
split := strings.Split(token, ".")
// Check for 2 dots
if strings.Count(token, ".") != 2 {
if len(split) != 3 {
return false
}
split := strings.Split(token, ".")
// Validate bot ID
// TODO: We could check the date on the snowflake
if _, err := strconv.ParseUint(utils.Base64Decode(split[0]), 10, 64); err != nil {
@ -97,12 +97,7 @@ func validateToken(token string) bool {
}
// Validate time
timestamp, err := base64.RawURLEncoding.DecodeString(split[1])
if err != nil {
return false
}
if len(timestamp) != 4 {
if _, err := base64.RawURLEncoding.DecodeString(split[1]); err != nil {
return false
}