func (a *Account) VerifyPassword(password []byte) (bool, bool, error) { valid, err := mcf.Verify(password, a.Password) if err != nil { return false, false, err } if !valid { return false, false, nil } current, err := mcf.IsCurrent(a.Password) if err != nil { return false, false, err } if !current { err := a.SetPassword(password) if err != nil { return true, false, err } a.DateModified = time.Now() return true, true, nil } return true, false, nil }
func TestVerificationExisting(t *testing.T) { for _, slot := range testData { valid, err := mcf.Verify(slot.plaintext, slot.encoded) if err != nil { panic(err) } if !valid { t.Fatalf("#1 Verify(%q, %q) failed", slot.plaintext, slot.encoded) } } }
func roundTrip(t *testing.T, plaintext string) { encoded, err := mcf.Create(plaintext) if err != nil { t.Fatal(err) } ok, err := mcf.Verify(plaintext, encoded) if err != nil { t.Fatal(err) } if !ok { t.Fatalf("Verify(%q, %q) failed", plaintext, encoded) } }