Commit ff627096 authored by David Venhoek's avatar David Venhoek Committed by Sietse Ringers
Browse files

Added missing error handling to keyshare server mail sending.

parent 95d5da10
...@@ -3,7 +3,6 @@ package keyshareserver ...@@ -3,7 +3,6 @@ package keyshareserver
import ( import (
"bytes" "bytes"
"crypto/rand" "crypto/rand"
"encoding/base32"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
...@@ -501,14 +500,7 @@ func (s *Server) handleRegister(w http.ResponseWriter, r *http.Request) { ...@@ -501,14 +500,7 @@ func (s *Server) handleRegister(w http.ResponseWriter, r *http.Request) {
} }
// Generate token // Generate token
tokenData := make([]byte, 35) token := server.NewSessionToken()
_, err = rand.Read(tokenData)
if err != nil {
s.conf.Logger.WithField("error", err).Error("Could not generate email verification token")
server.WriteError(w, server.ErrorInternal, err.Error())
return
}
token := base32.StdEncoding.EncodeToString(tokenData)
// Add it to the database // Add it to the database
err = s.db.AddEmailVerification(user, *msg.Email, token) err = s.db.AddEmailVerification(user, *msg.Email, token)
...@@ -535,6 +527,12 @@ func (s *Server) handleRegister(w http.ResponseWriter, r *http.Request) { ...@@ -535,6 +527,12 @@ func (s *Server) handleRegister(w http.ResponseWriter, r *http.Request) {
*msg.Email, *msg.Email,
subject, subject,
emsg.Bytes()) emsg.Bytes())
if err != nil {
s.conf.Logger.WithField("error", err).Error("Could not send email verifiation mail")
server.WriteError(w, server.ErrorInternal, err.Error())
return
}
} }
// Setup and return issuance session for keyshare credential. // Setup and return issuance session for keyshare credential.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment