2021-04-10 05:58:01 +00:00
|
|
|
package store
|
|
|
|
|
|
|
|
import "github.uio.no/torjus/apiary/models"
|
|
|
|
|
|
|
|
type LoginStats string
|
|
|
|
|
|
|
|
const (
|
|
|
|
LoginStatsUndefined LoginStats = ""
|
|
|
|
LoginStatsPasswords LoginStats = "password"
|
|
|
|
LoginStatsCountry LoginStats = "country"
|
2021-04-10 13:18:55 +00:00
|
|
|
LoginStatsIP LoginStats = "ip"
|
2021-04-10 05:58:01 +00:00
|
|
|
LoginStatsUsername LoginStats = "username"
|
2021-04-10 13:18:55 +00:00
|
|
|
LoginStatsTotals LoginStats = "total"
|
2021-04-10 05:58:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type StatsResult struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Count int `json:"count"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type LoginAttemptStore interface {
|
|
|
|
AddAttempt(l *models.LoginAttempt) error
|
|
|
|
All() ([]models.LoginAttempt, error)
|
|
|
|
Stats(statType LoginStats, limit int) ([]StatsResult, error)
|
|
|
|
}
|