Skip to content
Snippets Groups Projects
Commit 7579249b authored by Jonah Husson's avatar Jonah Husson
Browse files

Merge branch 'continueRegistration' into 'connectionRefactor'

Continue registration

See merge request !286
parents a24b9dd2 8ec4cc5b
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,8 @@ func Register(valueType, value string, publicKey []byte, regStatus func(int), ti ...@@ -66,6 +66,8 @@ func Register(valueType, value string, publicKey []byte, regStatus func(int), ti
if strings.Contains(response, keyFP) { if strings.Contains(response, keyFP) {
if strings.Contains(response, pushkeyExpected) { if strings.Contains(response, pushkeyExpected) {
submitted = true submitted = true
} else if strings.Contains(response, pushkeyErrorExpected) {
submitted = true
} else { } else {
err := errors.New(response) err := errors.New(response)
return errors.Wrap(err, "PushKey failed") return errors.Wrap(err, "PushKey failed")
...@@ -100,10 +102,21 @@ func Register(valueType, value string, publicKey []byte, regStatus func(int), ti ...@@ -100,10 +102,21 @@ func Register(valueType, value string, publicKey []byte, regStatus func(int), ti
case response = <-registerResponseListener: case response = <-registerResponseListener:
expected := "REGISTRATION COMPLETE" expected := "REGISTRATION COMPLETE"
unavalibleReg := "Can not register with existing email" unavalibleReg := "Can not register with existing email"
alreadyExists := "Cannot write to a user that already exists"
if strings.Contains(response, expected) { if strings.Contains(response, expected) {
complete = true complete = true
} else if strings.Contains(response, value) && strings.Contains(response, unavalibleReg) { } else if strings.Contains(response, value) && strings.Contains(response, unavalibleReg) {
return errors.New("Cannot register with existing username") return errors.New("Cannot register with existing username")
} else if strings.Contains(response, alreadyExists) {
id, b, err := Search("EMAIL", value, func(int) { return }, 1000*time.Millisecond)
if err != nil {
return errors.New("Cannot register with existing username")
}
if id != nil && bytes.Compare(b, publicKey) != 0 {
complete = true
} else {
return errors.New("Cannot register with existing username")
}
} }
case <-registerTimeout.C: case <-registerTimeout.C:
return errors.New("UDB register timeout exceeded on user submission") return errors.New("UDB register timeout exceeded on user submission")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment