func ValidateToken(token string) bool { if token == "" { return false } auth := hash(global.Password + global.Salt) t := time.Now().UTC() now := time.Date(t.Year(), t.Month(), 15, 0, 0, 0, 0, time.UTC) current := now.Format("200601") previous := now.AddDate(0, -1, 0).Format("200601") next := now.AddDate(0, 1, 0).Format("200601") ts := timeslot.Default() if token == hash(hash(current+auth)+ts.String()+global.Salt) || token == hash(hash(current+auth)+ts.Previous().String()+global.Salt) || token == hash(hash(current+auth)+ts.Next().String()+global.Salt) || token == hash(hash(previous+auth)+ts.String()+global.Salt) || token == hash(hash(previous+auth)+ts.Previous().String()+global.Salt) || token == hash(hash(previous+auth)+ts.Next().String()+global.Salt) || token == hash(hash(next+auth)+ts.String()+global.Salt) || token == hash(hash(next+auth)+ts.Previous().String()+global.Salt) || token == hash(hash(next+auth)+ts.Next().String()+global.Salt) { return true } return false }
func CurrentToken() string { auth := hash(global.Password + global.Salt) t := time.Now().UTC() now := time.Date(t.Year(), t.Month(), 15, 0, 0, 0, 0, time.UTC) current := now.Format("200601") ts := timeslot.Default() return hash(hash(current+auth) + ts.String() + global.Salt) }