Reorganize packages

This commit is contained in:
2021-10-21 12:36:01 +02:00
parent a71ff52ab4
commit 94e7faae78
15 changed files with 24 additions and 24 deletions

View File

@@ -0,0 +1,38 @@
package store
import "github.uio.no/torjus/apiary/models"
type LoginStats string
const (
LoginStatsUndefined LoginStats = ""
LoginStatsPasswords LoginStats = "password"
LoginStatsCountry LoginStats = "country"
LoginStatsIP LoginStats = "ip"
LoginStatsUsername LoginStats = "username"
LoginStatsTotals LoginStats = "total"
)
type AttemptQueryType string
const (
AttemptQueryTypeUsername AttemptQueryType = "username"
AttemptQueryTypePassword AttemptQueryType = "password"
AttemptQueryTypeIP AttemptQueryType = "ip"
)
type StatsResult struct {
Name string `json:"name"`
Count int `json:"count"`
}
type AttemptQuery struct {
QueryType AttemptQueryType
Query string
}
type LoginAttemptStore interface {
AddAttempt(l *models.LoginAttempt) error
All() ([]models.LoginAttempt, error)
Stats(statType LoginStats, limit int) ([]StatsResult, error)
Query(query AttemptQuery) ([]models.LoginAttempt, error)
}