(tx *storage.Connection, challenge *Challenge)
| 358 | return challenge |
| 359 | } |
| 360 | func (f *Factor) WriteChallengeToDatabase(tx *storage.Connection, challenge *Challenge) error { |
| 361 | if challenge.FactorID != f.ID { |
| 362 | return errors.New("Can only write challenges that you own") |
| 363 | } |
| 364 | now := time.Now() |
| 365 | f.LastChallengedAt = &now |
| 366 | if terr := tx.Create(challenge); terr != nil { |
| 367 | return terr |
| 368 | } |
| 369 | if err := tx.UpdateOnly(f, "last_challenged_at"); err != nil { |
| 370 | return err |
| 371 | } |
| 372 | return nil |
| 373 | } |
| 374 | |
| 375 | func (f *Factor) CreatePhoneChallenge(ipAddress string, otpCode string, encrypt bool, encryptionKeyID, encryptionKey string) (*Challenge, error) { |
| 376 | phoneChallenge := f.CreateChallenge(ipAddress) |
no test coverage detected