func (s *memStorage) CreatePassword(p storage.Password) (err error) { p.Email = strings.ToLower(p.Email) s.tx(func() { if _, ok := s.passwords[p.Email]; ok { err = storage.ErrAlreadyExists } else { s.passwords[p.Email] = p } }) return }
func (c *conn) CreatePassword(p storage.Password) error { p.Email = strings.ToLower(p.Email) _, err := c.Exec(` insert into password ( email, hash, username, user_id ) values ( $1, $2, $3, $4 ); `, p.Email, p.Hash, p.Username, p.UserID, ) if err != nil { return fmt.Errorf("insert password: %v", err) } return nil }