aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-15 18:56:42 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-15 18:56:42 +0100
commit1c2bc6bef2393ad48b743e2bb69c8930cc6226e7 (patch)
tree41beda50a6f89f1c3766e20f2a1ab8dcc707d4e7 /account.go
parent192235cb82b38862f3a53d7fb0100b17a17eb14c (diff)
Strip down NewAccount
Diffstat (limited to 'account.go')
-rw-r--r--account.go17
1 files changed, 11 insertions, 6 deletions
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
}