refactor code to fewer files; remove unused code
This commit is contained in:
38
core/nkode_policy.go
Normal file
38
core/nkode_policy.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type NKodePolicy struct {
|
||||
MaxNkodeLen int `json:"max_nkode_len"`
|
||||
MinNkodeLen int `json:"min_nkode_len"`
|
||||
DistinctSets int `json:"distinct_sets"`
|
||||
DistinctAttributes int `json:"distinct_attributes"`
|
||||
LockOut int `json:"lock_out"`
|
||||
Expiration int `json:"expiration"` // seconds, -1 no expiration
|
||||
}
|
||||
|
||||
func NewDefaultNKodePolicy() NKodePolicy {
|
||||
return NKodePolicy{
|
||||
MinNkodeLen: 4,
|
||||
MaxNkodeLen: 10,
|
||||
DistinctSets: 0,
|
||||
DistinctAttributes: 4,
|
||||
LockOut: 5,
|
||||
Expiration: -1,
|
||||
}
|
||||
}
|
||||
|
||||
var InvalidNKodeLen = errors.New("invalid nkode length")
|
||||
|
||||
func (p *NKodePolicy) ValidLength(nkodeLen int) error {
|
||||
|
||||
if nkodeLen < p.MinNkodeLen || nkodeLen > p.MaxNkodeLen {
|
||||
return InvalidNKodeLen
|
||||
}
|
||||
// TODO: validate Max > Min
|
||||
// Validate lockout
|
||||
// Add Lockout To User
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user