user signup sessions

This commit is contained in:
2024-08-19 19:13:17 -05:00
parent 8673eb9869
commit 603936b50c
8 changed files with 381 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ import (
type CustomerAttributes struct {
AttrVals []uint64
SetVals []uint64
keypadSize models.KeypadSize
KeypadSize models.KeypadSize
}
func NewCustomerAttributes(keypadSize models.KeypadSize) (*CustomerAttributes, error) {
@@ -31,17 +31,17 @@ func NewCustomerAttributes(keypadSize models.KeypadSize) (*CustomerAttributes, e
customerAttrs := CustomerAttributes{
AttrVals: attrVals,
SetVals: setVals,
keypadSize: keypadSize,
KeypadSize: keypadSize,
}
return &customerAttrs, nil
}
func (c *CustomerAttributes) Renew() error {
attrVals, errAttr := util.GenerateRandomNonRepeatingUint64(c.keypadSize.TotalAttrs())
attrVals, errAttr := util.GenerateRandomNonRepeatingUint64(c.KeypadSize.TotalAttrs())
if errAttr != nil {
return errAttr
}
setVals, errSet := util.GenerateRandomNonRepeatingUint64(c.keypadSize.AttrsPerKey)
setVals, errSet := util.GenerateRandomNonRepeatingUint64(c.KeypadSize.AttrsPerKey)
if errSet != nil {
return errSet
}
@@ -69,6 +69,6 @@ func (c *CustomerAttributes) GetAttrSetVal(attrVal uint64) (uint64, error) {
if indexOfAttr == -1 {
return 0, errors.New(fmt.Sprintf("No attribute %d", attrVal))
}
setIdx := indexOfAttr % c.keypadSize.AttrsPerKey
setIdx := indexOfAttr % c.KeypadSize.AttrsPerKey
return c.SetVals[setIdx], nil
}