aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
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
}