Clean up some error handling, remove debug logging
This commit is contained in:
parent
e082f55ebe
commit
5a7281f1ae
1 changed files with 4 additions and 3 deletions
|
@ -86,8 +86,10 @@ func register(w http.ResponseWriter, r *http.Request) {
|
|||
creds := &SignUpCredentials{}
|
||||
err := json.NewDecoder(r.Body).Decode(creds)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
returnError.Message = "unexpected error. please contact the administrator"
|
||||
render.JSON(w, r, returnError)
|
||||
return
|
||||
}
|
||||
if creds.Username == "" {
|
||||
|
@ -120,10 +122,10 @@ func register(w http.ResponseWriter, r *http.Request) {
|
|||
s := `INSERT INTO users (username, email, password, admin, verified)
|
||||
VALUES ($1, $2, $3, $4, $5)`
|
||||
if _, err = DB.Exec(s, creds.Username, creds.Email, string(hashedPassword), false, false); err != nil {
|
||||
fmt.Println(err)
|
||||
returnError.Message = "unexpected error. please contact the administrator"
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
render.JSON(w, r, returnError)
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
users.CreateProfile(creds.Username, creds.Email)
|
||||
|
@ -136,7 +138,6 @@ func register(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
if PostalEnabled {
|
||||
_, emailToken, _ := EmailAuth.Encode(claims)
|
||||
fmt.Println(emailToken)
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
//returnSuccess.Message = "User added. Please check your email for a verification link"
|
||||
returnSuccess.Message = emailToken
|
||||
|
|
Reference in a new issue