v0.0.53
This commit is contained in:
parent
1a1cd6d0aa
commit
aeded3fb37
@ -245,6 +245,35 @@ func (ph PassHash) WithTOTP(totpSecret []byte) (PassHash, error) {
|
||||
return "", errors.New("unknown version")
|
||||
}
|
||||
|
||||
func (ph PassHash) Change(newPlainPass string) (PassHash, error) {
|
||||
version, _, _, hastotp, totpsecret, valid := ph.Data()
|
||||
if !valid {
|
||||
return "", errors.New("invalid PassHash")
|
||||
}
|
||||
|
||||
if version == 0 {
|
||||
return HashPasswordV0(newPlainPass)
|
||||
}
|
||||
|
||||
if version == 1 {
|
||||
return HashPasswordV1(newPlainPass)
|
||||
}
|
||||
|
||||
if version == 2 {
|
||||
return HashPasswordV2(newPlainPass)
|
||||
}
|
||||
|
||||
if version == 3 {
|
||||
return HashPasswordV3(newPlainPass, langext.Conditional(hastotp, totpsecret, nil))
|
||||
}
|
||||
|
||||
if version == 4 {
|
||||
return HashPasswordV4(newPlainPass, langext.Conditional(hastotp, totpsecret, nil))
|
||||
}
|
||||
|
||||
return "", errors.New("unknown version")
|
||||
}
|
||||
|
||||
func (ph PassHash) String() string {
|
||||
return string(ph)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user