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{}
|
creds := &SignUpCredentials{}
|
||||||
err := json.NewDecoder(r.Body).Decode(creds)
|
err := json.NewDecoder(r.Body).Decode(creds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
returnError.Message = "unexpected error. please contact the administrator"
|
||||||
|
render.JSON(w, r, returnError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if creds.Username == "" {
|
if creds.Username == "" {
|
||||||
|
@ -120,10 +122,10 @@ func register(w http.ResponseWriter, r *http.Request) {
|
||||||
s := `INSERT INTO users (username, email, password, admin, verified)
|
s := `INSERT INTO users (username, email, password, admin, verified)
|
||||||
VALUES ($1, $2, $3, $4, $5)`
|
VALUES ($1, $2, $3, $4, $5)`
|
||||||
if _, err = DB.Exec(s, creds.Username, creds.Email, string(hashedPassword), false, false); err != nil {
|
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"
|
returnError.Message = "unexpected error. please contact the administrator"
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
render.JSON(w, r, returnError)
|
render.JSON(w, r, returnError)
|
||||||
fmt.Println(err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
users.CreateProfile(creds.Username, creds.Email)
|
users.CreateProfile(creds.Username, creds.Email)
|
||||||
|
@ -136,7 +138,6 @@ func register(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
if PostalEnabled {
|
if PostalEnabled {
|
||||||
_, emailToken, _ := EmailAuth.Encode(claims)
|
_, emailToken, _ := EmailAuth.Encode(claims)
|
||||||
fmt.Println(emailToken)
|
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
//returnSuccess.Message = "User added. Please check your email for a verification link"
|
//returnSuccess.Message = "User added. Please check your email for a verification link"
|
||||||
returnSuccess.Message = emailToken
|
returnSuccess.Message = emailToken
|
||||||
|
|
Reference in a new issue