aboutsummaryrefslogtreecommitdiff
path: root/register.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-11 00:33:57 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-11 00:33:57 +0100
commit8be17979faf2ba1a82570eb991e6d5149bf5654b (patch)
tree545bf82a463640da1851c800cf4736d4c70fad2a /register.go
parentfa26e22f7c442c0f434685130020a8b32b6ad7d9 (diff)
Add agree hook
Diffstat (limited to 'register.go')
-rw-r--r--register.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/register.go b/register.go
index 92355e0..a66fa3f 100644
--- a/register.go
+++ b/register.go
@@ -9,6 +9,8 @@ import (
"gopkg.in/square/go-jose.v1"
)
+var ErrMustAgree = errors.New("must agree to TOS")
+
// Registration Objects
type Registration struct {
Resource Resource `json:"resource"` // new-reg
@@ -20,7 +22,7 @@ type Registration struct {
CreatedAt *time.Time `json:"createdAt,omitempty"`
}
-func (p *Provider) Register(s Signer, c Contacts) error {
+func (p *Provider) Register(s Signer, c Contacts, agree func(string) bool) error {
// first step: new-reg
req := &Registration{
Resource: ResNewReg,
@@ -38,6 +40,10 @@ func (p *Provider) Register(s Signer, c Contacts) error {
return errors.New(resp.Status)
}
ns := parseHeader(resp)
+ tos := ns.Link["terms-of-service"]
+ if !agree(tos) {
+ return ErrMustAgree
+ }
// second step: reg, agree to tos
req = &Registration{