From 1c2bc6bef2393ad48b743e2bb69c8930cc6226e7 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 15 Dec 2015 18:56:42 +0100 Subject: Strip down NewAccount --- account.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'account.go') diff --git a/account.go b/account.go index 6a4e123..8ab9d1c 100644 --- a/account.go +++ b/account.go @@ -1,7 +1,6 @@ package acme import ( - "crypto/rand" "crypto/rsa" "encoding/json" "io" @@ -32,18 +31,24 @@ func newMail(email string) (Mail, error) { return mm, nil } +func newPhone(phone string) (Phone, error) { + p := strings.TrimSpace(phone) + return Phone(p), nil +} + // NewAccount ... -func NewAccount(email string, bits int) (*Account, error) { +func NewAccount(email, phone string, key *rsa.PrivateKey) (*Account, error) { + var c Contacts m, err := newMail(email) if err != nil { return nil, err } - key, err := rsa.GenerateKey(rand.Reader, bits) - if err != nil { - return nil, err + c = append(c, m) + if ph, _ := newPhone(phone); ph != "" { + c = append(c, ph) } return &Account{ - Contact: Contacts{m}, + Contact: c, PrivKey: key, }, nil } -- cgit v1.2.3